Ejemplo n.º 1
0
/**
 * generates a formatted price, including currency symbol
 *
 * @param array  $params parameters for the function
 * @param object $smarty the current Smarty object
 *
 * @return string HTML of the price
 */
function OnlineStore_productPriceFull2($params, $smarty)
{
    $params = array_merge(array('vat' => 0), $params);
    if (!$params['vat'] && $_SESSION['onlinestore_prices_shown_post_vat']) {
        $params['vat'] = 1;
    }
    $pid = $smarty->smarty->tpl_vars['product']->value->id;
    $product = Product::getInstance($pid);
    $vat = $params['vat'] ? (100 + $_SESSION['onlinestore_vat_percent']) / 100 : 1;
    $vatclass = $params['vat'] ? ' vat' : '';
    $sale_price = $product->getPriceSale();
    if ($sale_price) {
        $tmp = '<strike class="os_price">' . OnlineStore_numToPrice($product->getPrice() * $vat) . '</strike> <strong class="os_price with-sale-price' . $vatclass . '">' . OnlineStore_numToPrice($sale_price * $vat) . '</strong>';
    } else {
        $tmp = '<strong class="os_price' . $vatclass . '">' . OnlineStore_numToPrice($product->getPriceBase() * $vat) . '</strong>';
    }
    list($bp, $ba) = $product->getPriceBulkAll();
    if ($bp && $ba) {
        $tmp .= '<br />' . OnlineStore_numToPrice($bp * $vat) . ' for ' . $ba . ' or more';
    }
    $tmp = '<span class="os_full_price">' . $tmp . '</span>';
    return $tmp;
}
Ejemplo n.º 2
0
     $grandTotal -= $discount_amount;
 }
 // { postage
 $postage = OnlineStore_getPostageAndPackaging($deliveryTotal, @$_REQUEST['Country'], 0);
 if ($postage['total']) {
     $grandTotal += $postage['total'];
     $c .= '<tr class="os_basket_totals postage"><td class="p_and_p __" lang-context="core" ' . 'style="text-align: right;" colspan="3">' . __('Postage and Packaging', 'core') . '</td><td class="totals">' . OnlineStore_numToPrice($postage['total']) . '</td></tr>';
 }
 // }
 if ($vattable && $_SESSION['onlinestore_vat_percent']) {
     $c .= '<tr class="os_basket_totals vat">' . '<td style="text-align:right" class="vat" colspan="3">' . '<span>' . __('VAT', 'core') . '</span> ( ' . $_SESSION['onlinestore_vat_percent'] . ' % ' . __('on', 'core') . OnlineStore_numToPrice($vattable) . ' )</td><td class="totals">';
     $vat = $vattable * ($_SESSION['onlinestore_vat_percent'] / 100);
     $c .= OnlineStore_numToPrice($vat) . '</td></tr>';
     $grandTotal += $vat;
 }
 $c .= '<tr class="os_basket_totals total-due"><td style="text-align: right;" colspa' . 'n="3">' . __('Total Due', 'core') . '</td>' . '<td class="totals">' . OnlineStore_numToPrice($grandTotal) . '</td></tr>' . '</table>';
 if ($has_vatfree) {
     $c .= '<div><sup>1</sup><span>' . __('VAT-free item', 'core') . '</span></div>';
 }
 // }
 // { show details form
 $_POST['_viewtype'] = $pviewtype;
 $txt = isset($PAGEDATA->vars['online_stores_proceedToPayment']) ? $PAGEDATA->vars['online_stores_proceedToPayment'] : 'Proceed to Payment';
 if ($pviewtype == 1 && $viewtype == 1 || !$pviewtype) {
     $c .= '<form method="post">' . $PAGEDATA->render() . '<input type="hidden" name="viewtype" value="1"/>' . '<input type="hidden" name="action" value="Proceed to Payment" />' . '<button>' . __($txt, 'core') . '</button>' . '</form>';
 } else {
     if ($pviewtype == 2 || $pviewtype == 3) {
         $c .= '<div id="online-store-wrapper" class="online-store"></div>';
     } else {
         $c .= '<form method="post" action="' . $PAGEDATA->getRelativeUrl() . '">' . '<input type="hidden" name="viewtype" value="1"/>' . '<button class="onlinestore-view-checkout __" lang-context="core">' . __('Checkout', 'core') . '</button></form>';
     }
Ejemplo n.º 3
0
/**
 * returns a HTML string to show the Online-Store basket
 *
 * @param array $vars parameters passed via Smarty
 *
 * @return string
 */
function OnlineStore_showBasketWidget($vars = null)
{
    global $DBVARS;
    $slidedown = @$vars->slidedown;
    $slideup = (int) @$vars->slideup_delay;
    $html = '<div class="online-store-basket-widget' . ($slidedown ? ' slidedown' : '') . '">';
    if ($slidedown) {
        $html .= '<div class="slidedown-header">' . __('Your Items') . '</div>' . '<div class="slidedown-wrapper" slidedown="' . @$vars->slidedown_animation . '" slideup="' . $slideup . '">';
        WW_addCSS('/ww.plugins/online-store/basket.css');
    }
    // { basket body
    if (!isset($_SESSION['online-store'])) {
        $_SESSION['online-store'] = array('items' => array(), 'total' => 0);
    }
    $cpage = Page::getInstance($_SESSION['onlinestore_checkout_page']);
    $cpage = $cpage->getRelativeUrl();
    if (@$vars->template) {
        $t = $vars->template;
        $t = str_replace('{{ONLINESTORE_NUM_ITEMS}}', OnlineStore_getNumItems(), $t);
        if (!@$_SESSION['onlinestore_checkout_page']) {
            OnlineStore_setCheckoutPage();
        }
        $total = OnlineStore_getFinalTotal();
        if ($_SESSION['onlinestore_prices_shown_post_vat']) {
            $total *= (100 + $_SESSION['onlinestore_vat_percent']) / 100;
        }
        $t = str_replace('{{ONLINESTORE_FINAL_TOTAL}}', OnlineStore_numToPrice($total), $t);
        if (strpos($t, '{{ONLINESTORE_CHECKOUTURL}}') !== false) {
            $t = str_replace('{{ONLINESTORE_CHECKOUTURL}}', $cpage, $t);
        }
        $html .= $t;
    } else {
        if (isset($_SESSION['online-store']['items']) && count($_SESSION['online-store']['items'])) {
            $html .= '<table class="os_basket">';
            $html .= '<tr class="os_basket_titles"><th>' . __('Price') . '</th><th>' . __('Amt') . '</th>' . '<th>' . __('Total') . '</th></tr>';
            foreach ($_SESSION['online-store']['items'] as $md5 => $item) {
                // { name
                $html .= '<tr class="os_basket_itemTitle" product="' . $md5 . '">' . '<th colspan="3">';
                if (isset($item['id']) && $item['id']) {
                    $p = Product::getInstance($item['id']);
                    if ($p) {
                        $img = $p->getDefaultImage();
                        if ($img) {
                            $html .= '<a href="/f/' . $img . '" target="popup" ' . 'class="online-store-thumb-wrapper">' . '<img src="/a/f=getImg/w=16/h=16/' . $img . '"/>' . '</a>';
                        }
                    }
                }
                if ($item['url']) {
                    $html .= '<a href="' . $item['url'] . '">';
                }
                $html .= $item['short_desc'];
                if ($item['url']) {
                    $html .= '</a>';
                }
                $html .= '</th></tr>';
                // }
                $html .= '<tr class="os_basket_itemDetails ' . $md5 . '" product="' . $md5 . '">';
                // { cost
                $cost = $_SESSION['onlinestore_prices_shown_post_vat'] ? $item['cost'] * (100 + $_SESSION['onlinestore_vat_percent']) / 100 : $item['cost'];
                $html .= '<td>' . OnlineStore_numToPrice($cost) . '</td>';
                // }
                // { amount
                $html .= '<td class="amt"><span class="' . $md5 . '-amt">' . $item['amt'] . '</span>' . ' [<a title="remove" class="amt-del" href="javascript:;">x</a>]' . '</td>';
                // }
                // { price
                $price = $cost * $item['amt'];
                $html .= '<td class="' . $md5 . '-item-total total">' . OnlineStore_numToPrice($price) . '</td></tr>';
                // }
            }
            $total = $_SESSION['online-store']['total'];
            if ($_SESSION['onlinestore_prices_shown_post_vat']) {
                $total *= (100 + $_SESSION['onlinestore_vat_percent']) / 100;
            }
            $html .= '<tr class="os_basket_totals"><th colspan="2">' . __('Total') . '</th>' . '<td class="total">' . OnlineStore_numToPrice($total) . '</td></tr>' . '</table>' . '<a class="online-store-checkout-link" href="' . $cpage . '">' . __('Proceed to Checkout') . '</a>';
        } else {
            $html .= '<em class="os-basket empty">' . __('Empty') . '</em>';
        }
    }
    if (@$_SESSION['userdata']['id']) {
        $html .= '<div id="onlinestore-lists"><span>' . __('Lists:') . ' </span>' . '<a href="javascript:;" class="onlinestore-load-list">' . __('Load') . '</a>';
        if (count(@$_SESSION['online-store']['items'])) {
            $html .= ' | <a href="javascript:;" class="onlinestore-save-list">' . __('Save') . '</a>';
        }
        $html .= '</div>';
    }
    // }
    if ($slidedown) {
        $html .= '</div>';
    }
    $html .= '</div>';
    WW_addScript('online-store/j/basket.js');
    return $html;
}
Ejemplo n.º 4
0
/**
 * get HTML for the Products widget
 *
 * @param array $vars any parameters to pass to the widget
 *
 * @return string HTML of the widget
 */
function Products_widget($vars = null)
{
    $html = '';
    $widget_type = isset($vars->widget_type) && $vars->widget_type ? $vars->widget_type : 'List Categories';
    $diameter = isset($vars->diameter) && $vars->diameter ? $vars->diameter : 280;
    $parent_cat = isset($vars->parent_cat) ? (int) $vars->parent_cat : 0;
    switch ($widget_type) {
        case 'Pie Chart':
            // { Pie Chart
            $id = 'products_categories_' . md5(rand());
            $cats = dbAll('select id,name,associated_colour as col from products_categories ' . 'where parent_id=' . $parent_cat . ' and enabled order by sortNum', false, 'products_categories');
            $html .= '<div id="' . $id . '" class="products-widget" style="width:' . $diameter . 'px;height:' . ($diameter + 30) . 'px">' . __('Loading...') . '</div>' . '<script defer="defer">$(function(){' . 'products_widget("' . $id . '",' . json_encode($cats) . ');' . '});</script>';
            $html .= '<!--[if IE]><script defer="defer" src="/ww.plugins/products/' . 'frontend/excanvas.js"></script><![endif]-->';
            WW_addScript('products/frontend/jquery.canvas.js');
            WW_addScript('products/frontend/widget.js');
            break;
            // }
        // }
        case 'Products':
            // { Products
            $html = '<div class="products-widget-products">';
            $products = Products::getByCategory($parent_cat);
            foreach ($products->product_ids as $pid) {
                $product = Product::getInstance($pid);
                $iid = $product->getDefaultImage();
                $img = $iid ? '<a class="product-widget-imglink" href="' . $product->getRelativeURL() . '"><img class="product-widget-img" src="' . $GLOBALS['cdnprefix'] . '/a/w=200/h=auto/f=getImg/' . $iid . '"/></a>' : '';
                $pvat = array("vat" => $_SESSION['onlinestore_vat_percent']);
                $html .= '<div class="products-widget-inner">' . $img . '<p class="products-widget-name">' . htmlspecialchars(__FromJson($product->name)) . '</p>' . '<div class="products-widget-price">' . '<p class="products-widget-price-inner">' . OnlineStore_numToPrice($product->getPriceBase() * (1 + $pvat['vat'] / 100)) . '</p></div>' . '<a class="product-widget-link" href="' . $product->getRelativeURL() . '">' . __('more info') . '</a></div>';
            }
            $html .= '</div>';
            break;
            // }
        // }
        case 'Most Popular Products':
            // {
            $html = '';
            $pids = array();
            if ($parent_cat) {
                $products = Products::getByCategory($parent_cat);
                $rs = dbAll('select sum(quantity) as amt,product_id from online_store_sales' . ' where product_id in (' . join(', ', $products->product_ids) . ')' . ' group by product_id order by amt desc limit 8', '', 'online_store_sales');
            } else {
                $rs = dbAll('select sum(quantity) as amt,product_id from online_store_sales' . ' where product_id>0' . ' group by product_id order by amt desc limit 8', '', 'online_store_sales');
            }
            foreach ($rs as $r) {
                $pid = $r['product_id'];
                $product = Product::getInstance($pid);
                if (!$product->name) {
                    dbQuery('update online_store_sales set product_id=-' . $pid . ' where product_id="' . $pid . '"');
                    Core_cacheClear('online_store_sales');
                    continue;
                }
                $iid = $product->getDefaultImage();
                $img = $iid ? '<a class="product-widget-imglink" href="' . $product->getRelativeURL() . '"><img class="product-widget-img" src="' . $GLOBALS['cdnprefix'] . '/a/w=200/h=auto/f=getImg/' . $iid . '"/></a>' : '';
                $pvat = array("vat" => $_SESSION['onlinestore_vat_percent']);
                $html .= '<div class="products-widget-inner">' . $img . '<p class="products-widget-name">' . htmlspecialchars(__FromJson($product->name)) . '</p>' . '<div class="products-widget-price">' . '<p class="products-widget-price-inner">' . OnlineStore_numToPrice($product->getPriceBase() * (1 + $pvat['vat'] / 100)) . '</p></div>' . '<a class="product-widget-link" href="' . $product->getRelativeURL() . '">' . __('more info') . '</a></div>';
            }
            break;
            // }
        // }
        case 'Tree View':
            // { Tree View
            $html = '<div class="product-categories-tree"><ul>';
            $cats = dbAll('select id,name,associated_colour as col from products_categories ' . 'where parent_id=' . $parent_cat . ' and enabled order by sortNum', false, 'products_categories');
            foreach ($cats as $c) {
                $cat = ProductCategory::getInstance($c['id']);
                $name = $c['name'];
                $html .= '<li class="products-cat-' . preg_replace('/[^a-zA-Z0-9\\-_]/', '', $name) . '">' . '<a href="' . $cat->getRelativeUrl() . '">' . htmlspecialchars($name) . '</a>';
                $html .= Products_categoriesListSubCats($c['id']);
                $html .= '</li>';
            }
            $html .= '</ul></div>';
            WW_addScript('/j/jstree/jquery.jstree.js');
            WW_addScript('products/j/categories-tree.js');
            break;
            // }
        // }
        default:
            // { List Categories
            $html = '<ul class="product-categories">';
            $cats = dbAll('select id,name,associated_colour as col from products_categories ' . 'where parent_id=' . $parent_cat . ' and enabled order by sortNum', false, 'products_categories');
            foreach ($cats as $c) {
                $name = $c['name'];
                $html .= '<li class="products-cat-' . preg_replace('/[^a-zA-Z0-9\\-_]/', '', $name) . '">' . '<a data-cid="' . $c['id'] . '"' . ' href="/_r?type=products&product_cid=' . $c['id'] . '">' . $name . '</a>';
                if (isset($vars->show_products) && $vars->show_products == '1') {
                    $cs2 = ProductsCategoriesProducts::getByCategoryId($c['id']);
                    if (count($cs2)) {
                        $ps = dbAll('select id, name from products where id in (' . join(',', $cs2) . ')');
                        $html .= '<ul class="products-products">';
                        foreach ($ps as $p) {
                            $product = Product::getInstance($p['id']);
                            $html .= '<li><a data-pid="' . $p['id'] . '" href="' . $product->getRelativeUrl() . '">' . htmlspecialchars(__FromJson($p['name'])) . '</a></li>';
                        }
                        $html .= '</ul>';
                    }
                }
                $html .= '</li>';
            }
            $html .= '</ul>';
            if (@$_SESSION['userdata']['id']) {
                WW_addScript('products/j/watchlists.js');
            }
            break;
            // }
    }
    return $html;
}
Ejemplo n.º 5
0
/**
 * return the sale price for the product
 *
 * @param array  $params parameters
 * @param object $smarty Smarty object
 *
 * @return string HTML
 */
function Products_priceSale2($params, $smarty)
{
    $pid = $smarty->smarty->tpl_vars['product']->value->id;
    if ((!isset($params['vat']) || !$params['vat']) && $_SESSION['onlinestore_prices_shown_post_vat']) {
        $params['vat'] = 1;
    }
    $product = Product::getInstance($pid);
    if (!isset($product->vals['os_base_price'])) {
        return '0';
    }
    $vat = isset($params['vat']) && $params['vat'] ? (100 + $_SESSION['onlinestore_vat_percent']) / 100 : 1;
    return OnlineStore_numToPrice($product->getPrice('sale') * $vat, true, (int) @$params['round']);
}
        break;
    case '2':
        $status = 'Dispatched';
        break;
    case '3':
        $status = 'Cancelled';
        break;
    case '4':
        $status = 'Authorised';
        break;
    case '5':
        $status = 'Prepared';
        break;
    default:
        $status = 'Status number ' . $iid['status'] . ' is unknown';
        break;
}
$html = '<h2>' . __('Online Store - Order History - Invoice', 'core') . ' ' . $iid['id'] . '</h2>' . '<a href="' . $PAGEDATA->getRelativeUrl() . '">' . __('back to profile', 'core') . '</a>' . '<table class="onlinestore-purchase-details">' . '<tr><th>' . __('Invoice ID') . '</th><td>' . $iid['id'] . '</td></tr>' . '<tr><th>' . __('Date') . '</th><td>' . Core_DateM2H($iid['date_created'], 'datetime') . '</td></tr>' . '<tr><th>' . __('Total') . '</th><td>' . OnlineStore_numToPrice($iid['total']) . '</td></tr>' . '<tr><th>' . __('Status') . '</th><td>' . $status . '</td></tr>' . '<tr><th>' . __('Invoice') . '</th><td><a href="/a/p=online-store/f=invoicePdf/id=' . $iid['id'] . '">' . __('PDF') . '</a></td></tr>';
// { list of items
$html .= '<tr><th>' . __('Items Purchased') . '</th><td>' . '<table class="onlinestore-item-details"><tr><th>' . __('Description') . '</th>' . '<th>' . __('Amount') . '</th><th>' . __('Cost') . '</th></tr>';
$items = json_decode($iid['items'], true);
foreach ($items as $item) {
    $desc = $item['short_desc'];
    if ($item['long_desc']) {
        $desc .= '<br/>' . $item['long_desc'];
    }
    $html .= '<tr><td><a href="' . $item['url'] . '">' . $desc . '</a></td>' . '<td>' . $item['amt'] . '</td><td>' . OnlineStore_numToPrice($item['cost']) . '</td></tr>';
}
$html .= '</table></td></tr>';
// }
$html .= '</table>';