示例#1
0
/**
 * display functions
 */
function renderItem(MESH\Commerce\Carts\CartItem $item)
{
    $products = '';
    foreach ($item->getProducts() as $product) {
        $products .= renderProduct($product);
    }
    return theme('cart-item', array('type' => $item->getType(), 'products' => $products));
}
示例#2
0
    $oApp->render("about.phtml");
});
$oApp->get("/contact", function () use($oApp) {
    $oApp->render("contact.phtml");
});
$oApp->get("/privacy", function () use($oApp) {
    $oApp->render("privacy.phtml");
});
$oApp->get("/success", function () use($oApp) {
    $oApp->render("success.phtml");
});
$oApp->get("/failure", function () use($oApp) {
    $oApp->render("failure.phtml");
});
$oApp->get("/products/:productID", function ($nId) {
    renderProduct($nId);
});
$oApp->run();
function renderProduct($nId)
{
    global $oApp, $oDb;
    // fetching product
    $oStmt = $oDb->prepare("SELECT * FROM products WHERE productID = :id");
    $oStmt->bindParam("id", $nId);
    $oStmt->execute();
    $aProduct = $oStmt->fetchAll(PDO::FETCH_OBJ);
    //fetching images
    $oStmt = $oDb->prepare("SELECT * FROM images WHERE productID = :id");
    $oStmt->bindParam("id", $nId);
    $oStmt->execute();
    $aImages = $oStmt->fetchAll(PDO::FETCH_OBJ);
示例#3
0
 */
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($code != 200) {
    switch ($code) {
        case 404:
            $error = $data->error->message;
            echo theme('failure', array('error' => $error));
            break;
        default:
            $error = $data->error->message;
            echo theme('failure', array('error' => $error));
            break;
    }
    die;
}
echo renderProduct($data);
/**
 * display functions
 */
function displayImage($img, $width, $height)
{
    if (!isset($img->resizingService->href)) {
        return '';
    }
    if (!isset($img->resizingService->properties)) {
        return '';
    }
    $properties = $img->resizingService->properties;
    $url = $img->resizingService->href;
    /**
     * How to get a resized image
示例#4
0
<?php

require '../bootstrap.php';
require '../includes.php';
$mesh = getSDK();
$product = $mesh->products->createProduct('193965');
$product->addParam('expand', array('variations', 'reviews', 'informationBlocks', 'customisations', 'freeDelivery'));
// alternative
$product->expand('descriptionhtml');
try {
    $product->load();
    echo renderProduct($product);
} catch (MESH\Commerce\Exceptions\NotFoundException $e) {
    echo theme('failure', array('error' => $e->getMessage()));
    die;
} catch (MESH\Commerce\Exceptions\MeshException $e) {
    echo theme('failure', array('error' => $e->getMessage()));
    die;
}
/**
 * display functions
 */
function displayImage(MESH\Commerce\Products\ResizableImage $img, $width, $height)
{
    return '<img src="' . $img->getResizedUrl($width, $height) . '" />';
}
function renderProduct(MESH\Commerce\Products\Product $product)
{
    $vars = array('name' => $product->getName(), 'main' => displayImage($product->getMainImage(), 300, 300), 'images' => array());
    $imgs = array();
    foreach ($product->getImages() as $img) {