/**
  * Constructor
  */
 private function __construct()
 {
     // Register post type and settings
     add_action('init', [$this, 'registerPostType']);
     add_filter('init', [$this, 'registerTaxonomies']);
     add_filter('init', [$this, 'registerFields']);
     // Edit search template
     add_filter('search_template', [$this, 'registerSearchTemplate']);
     add_filter('wp_title', [$this, 'fixSearchTitle'], 5, 3);
     // Apply price discounts on save
     add_action('acf/save_post', [$this, 'saveDiscountedPrice'], 20);
     // Set default product meta query
     add_filter('cgit_product_meta_query', [$this, 'setMetaQuery'], 10, 2);
     // Register widgets
     add_action('widgets_init', [$this, 'registerWidgets']);
     // Initialize catalogue
     Catalogue::getInstance();
 }
Пример #2
0
     foreach ($inventory as $product) {
         $subtotal += $product['price'] * $product['quantity'];
         $product['line'] = $product['price'];
         $price_total = $product['price'] * $product['quantity'];
         $product['price_total'] = number_format($price_total, 2);
         $product['line_formatted'] = Tax::getInstance()->priceFormat($product['price']);
         $product['price_total_formatted'] = Tax::getInstance()->priceFormat($price_total);
         $product['options'] = Catalogue::getInstance()->displayProductOptions($product['product_id'], unserialize($product['options_array']));
         $product['options_array'] = false;
         if (!empty($product['product_options']) && preg_match('/^a:[0-9]/', $product['product_options'])) {
             $product['options_array'] = cc_unserialize($product['product_options']);
             $product['options_text'] = implode(' ', cc_unserialize($product['product_options']));
         } elseif (!empty($product['product_options'])) {
             $product['options_text'] = $product['product_options'];
         }
         $product['line_price_less_options'] = sprintf("%.2F", $product['line'] - Catalogue::getInstance()->getOptionsLinePrice());
         $smarty_data['products'][] = $product;
     }
     $GLOBALS['smarty']->assign('PRODUCTS', $smarty_data['products']);
     $GLOBALS['smarty']->assign('SUBTOTAL', number_format($subtotal, 2));
 }
 // Assign summary to overview
 $overview_summary = $summary[0];
 $overview_summary['percent'] = '';
 if ($overview_summary['discount_type'] == 'p') {
     $overview_summary['percent'] = number_format($overview_summary['discount'] / $overview_summary['subtotal'] * 100) . '%';
 } else {
     if ($overview_summary['discount_type'] == 'pp') {
         $overview_summary['percent'] = number_format($overview_summary['discount'] / ($overview_summary['subtotal'] + $overview_summary['discount']) * 100) . '%';
     }
 }
Пример #3
0
$GLOBALS['hooks'] = HookLoader::getInstance();
//Initialize SEO
$GLOBALS['seo'] = SEO::getInstance();
if (isset($_GET['seo_path']) && !empty($_GET['seo_path'])) {
    $_GET['seo_path'] = preg_replace('/(\\/\\~[a-z0-9]{1,}\\/)/', '', $_GET['seo_path']);
    // Remove /~username/ from seo_path
    $GLOBALS['seo']->getItem($_GET['seo_path']);
}
//Initialize SSL
$GLOBALS['ssl'] = SSL::getInstance();
//Initialize GUI
$GLOBALS['gui'] = GUI::getInstance();
//Initialize Taxes
$GLOBALS['tax'] = Tax::getInstance();
//Initialize catalogue
$GLOBALS['catalogue'] = Catalogue::getInstance();
//Initialize cubecart
$GLOBALS['cubecart'] = Cubecart::getInstance();
//Initialize user
$GLOBALS['user'] = User::getInstance();
//Initialize cart
$GLOBALS['cart'] = Cart::getInstance();
// Set store timezone - default to UTC
date_default_timezone_set($GLOBALS['config']->get('config', 'time_zone') ? $GLOBALS['config']->get('config', 'time_zone') : 'UTC');
if ($GLOBALS['config']->get('config', 'recaptcha') && !$GLOBALS['session']->get('confirmed', 'recaptcha')) {
    $recaptcha['error'] = null;
    $recaptcha['confirmed'] = false;
    if ($GLOBALS['config']->get('config', 'recaptcha') == 2 && isset($_POST['g-recaptcha-response'])) {
        if (empty($_POST['g-recaptcha-response'])) {
            $recaptcha['error'] = $GLOBALS['language']->form['verify_human_fail'];
        } else {
    $GLOBALS['main']->addTabControl($lang['catalogue']['title_manufacturer'], false, currentPage(array('edit')));
    $GLOBALS['main']->addTabControl($lang['catalogue']['title_manufacturer_edit'], 'manu_edit');
    if (($manufacturers = $GLOBALS['db']->select('CubeCart_manufacturers', array('name', 'id', 'URL'), array('id' => (int) $_GET['edit']))) !== false) {
        $GLOBALS['smarty']->assign('EDIT', $manufacturers[0]);
    } else {
        $GLOBALS['main']->setACPWarning($lang['catalogue']['error_manufacturer_found']);
        httpredir(currentPage(array('edit')));
    }
    foreach ($GLOBALS['hooks']->load('admin.product.manufacturer.tabs') as $hook) {
        include $hook;
    }
    $GLOBALS['smarty']->assign('PLUGIN_TABS', $smarty_data['plugin_tabs']);
    $GLOBALS['smarty']->assign('DISPLAY_FORM', true);
} else {
    $GLOBALS['main']->addTabControl($lang['catalogue']['title_manufacturer'], 'manufacturers');
    $GLOBALS['main']->addTabControl($lang['catalogue']['title_manufacturer_add'], 'manu_add');
    $catalogue = Catalogue::getInstance();
    $page = isset($_GET['page']) ? $_GET['page'] : 1;
    $per_page = 10;
    if (($manufacturers = $GLOBALS['db']->select('CubeCart_manufacturers', false, false, 'name', $per_page, $page)) !== false) {
        $GLOBALS['smarty']->assign('PAGINATION', $GLOBALS['db']->pagination(false, $per_page, $page));
        foreach ($manufacturers as $i => $manufacturer) {
            if (filter_var($manufacturer['URL'], FILTER_VALIDATE_URL)) {
                $manufacturers[$i]['name'] = '<a href="' . $manufacturer['URL'] . '" target="_blank">' . $manufacturer['name'] . '</a>';
            }
        }
        $GLOBALS['smarty']->assign('MANUFACTURERS', $manufacturers);
    }
    $GLOBALS['smarty']->assign('DISPLAY_LIST', true);
}
$page_content = $GLOBALS['smarty']->fetch('templates/products.manufacturers.php');
Пример #5
0
 /**
  * Dynamic template load
  *
  * @param string $type
  * @param string $search_string
  * @return data/false
  */
 public static function template($type, $search_string)
 {
     switch (strtolower($type)) {
         case 'prod_options':
             $options['options'] = Catalogue::getInstance()->displayProductOptions($search_string);
             $GLOBALS['smarty']->assign('product', $options);
             die($GLOBALS['smarty']->fetch('templates/element.product_options.php'));
             break;
     }
     return false;
 }