예제 #1
0
 /**
  * Send 'update_cart' event
  */
 public static function UpdateCartEvent($data)
 {
     try {
         $mod_convead = new Convead(false);
         if ($mod_convead->settings['enabled'] == '0' || empty($mod_convead->settings['app_key'])) {
             return;
         }
         $mod_convead->initConveadClient();
         $eventItems = array();
         $cartItems = \Cart\BaseCart::getInstance()->getItems();
         // Cast cart items to Convead event format
         foreach ($cartItems['data'] as $item) {
             $eventItems[] = array('product_id' => $item->data['id'], 'qnt' => $item->data['quantity'], 'price' => $item->data['price']);
         }
         $mod_convead->conveadClient->eventUpdateCart($eventItems);
     } catch (Exception $e) {
         return true;
     }
 }
예제 #2
0
 /**
  * get gift certificate in json format
  * @access public
  * @author DevImageCms
  * @param (string) key optional
  * @param (float) totalPrice optional
  * @return jsoon
  * @copyright (c) 2013, ImageCMS
  */
 public function getGiftCertificate($key = null, $totalPrice = null)
 {
     $cart = \Cart\BaseCart::getInstance();
     $this->baseDiscount = \mod_discount\classes\BaseDiscount::create();
     if ($totalPrice === null) {
         $totalPrice = $cart->getTotalPrice();
     }
     if (null === $key) {
         $key = strip_tags(trim($_GET['key']));
     }
     foreach ($this->baseDiscount->discountType['all_order'] as $disc) {
         if ($disc['key'] == $key and $disc['is_gift']) {
             $value = $this->baseDiscount->getDiscountValue($disc, $totalPrice);
             return json_encode(array('key' => $disc['key'], 'val_orig' => $value, 'value' => \ShopCore::app()->SCurrencyHelper->convert($value), 'gift_array' => $disc));
             break;
         }
     }
     return json_encode(array('error' => true, 'mes' => lang('Invalid code try again', 'mod_discount')));
 }
예제 #3
0
 /**
  * __construct base object loaded
  * @access private
  * @author DevImageCms
  * @param ---
  * @return ---
  * @copyright (c) 2013, ImageCMS
  */
 private function __construct()
 {
     $this->ci =& get_instance();
     if (\mod_discount\classes\BaseDiscount::checkModuleInstall()) {
         require_once __DIR__ . '/../models/discount_model_front.php';
         $this->ci->discount_model_front = new \discount_model_front();
         $lang = new \MY_Lang();
         $lang->load('mod_discount');
         $this->cart = \Cart\BaseCart::getInstance();
         if (!self::$userId) {
             $this->userGroupId = $this->ci->dx_auth->get_role_id();
             $this->userId = $this->ci->dx_auth->get_user_id();
         } else {
             $this->userId = self::$userId;
             $this->userGroupId = $this->ci->db->where('id', $this->userId)->get('users')->row()->role_id;
         }
         if (!self::$ignoreCart) {
             $this->cartData = $this->getCartData();
         }
         $this->amoutUser = $this->ci->discount_model_front->getAmoutUser($this->userId);
         $this->totalPrice = !self::$totalPrice ? $this->cart->getOriginTotalPrice() : self::$totalPrice;
         $this->allDiscount = $this->getAllDiscount();
         $this->discountType = $this->collectType($this->allDiscount);
         $this->discountAllOrder = $this->getAllOrderDiscountNotRegister();
         if ($this->userId) {
             $this->discountUser = $this->getUserDiscount();
             $this->discountGroupUser = $this->getUserGroupDiscount();
             $this->discountComul = $this->getComulativDiscount();
             $this->discountAllOrder = $this->getAllOrderDiscountRegister();
         }
         $this->discountProductVal = self::$ignoreCart ? null : $this->getDiscountProducts();
         $this->discountMax = $this->getMaxDiscount(array($this->discountUser, $this->discountGroupUser, $this->discountComul, $this->discountAllOrder), $this->totalPrice);
         $this->discountNoProductVal = $this->getDiscountValue($this->discountMax, $this->totalPrice);
     }
 }
예제 #4
0
 public function updateDiscountsApplies()
 {
     \mod_discount\classes\BaseDiscount::prepareOption(array('reBuild' => 1));
     $baseDiscount = \mod_discount\classes\BaseDiscount::create();
     if (\mod_discount\classes\BaseDiscount::checkModuleInstall()) {
         if ($baseDiscount->discountProductVal > $baseDiscount->discountNoProductVal) {
             $discount['result_sum_discount'] = $baseDiscount->discountProductVal;
             $discount['type'] = 'product';
         } else {
             $discount['result_sum_discount'] = $baseDiscount->discountNoProductVal;
             $discount['type'] = 'user';
         }
         if ($discount['result_sum_discount'] > 0) {
             if ($discount['type'] != 'product') {
                 $baseDiscount->updateDiskApply($baseDiscount->discountMax['key']);
             } else {
                 $cartItems = \Cart\BaseCart::getInstance()->getItems();
                 $diff = 0;
                 foreach ($cartItems['data'] as $item) {
                     if (is_null($item->discountKey)) {
                         continue;
                     }
                     $appliesLeft = \mod_discount\classes\BaseDiscount::create()->getAppliesLeft($item->discountKey);
                     if ($appliesLeft === null) {
                         continue;
                     }
                     for ($i = 0; $i < $item->quantity; $i++) {
                         if ($appliesLeft-- > 0) {
                             \mod_discount\classes\BaseDiscount::create()->updateDiskApply($item->discountKey);
                         }
                     }
                     if ($appliesLeft < 0) {
                         $appliesLeft = abs($appliesLeft);
                         $diff += ($item->originPrice - $item->price) * $appliesLeft;
                     }
                 }
                 if ($diff > 0) {
                     \CMSFactory\Events::create()->setListener(function (\SOrders $order, $price) use($diff) {
                         if (Mod_discount::$orderPassOverloadControl == false) {
                             $price = $order->getTotalPrice() + $diff;
                             $discount = $order->getDiscount() - $diff;
                             $order->setTotalPrice($price)->save();
                             Mod_discount::$orderPassOverloadControl = true;
                         }
                     }, 'Cart:MakeOrder');
                 }
             }
         }
     }
 }
예제 #5
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     $this->object = \Cart\BaseCart::getInstance();
 }
<?php

$cart = \Cart\BaseCart::getInstance();
$count = $cart->getTotalItems();
$price = $cart->getTotalPrice();
$priceOrigin = $cart->getOriginTotalPrice();
?>

<?php 
if ($count == 0) {
    ?>
    <div class="btn-bask">
        <button>
            <span class="frame-icon">
                <span class="icon_cleaner"></span>
            </span>
            <span class="text-cleaner">
                <span class="helper"></span>
                <span>
                    <span class="text-el topCartCount">0</span>
                </span>
            </span>
        </button>
    </div>
<?php 
} else {
    ?>
    <div class="btn-bask pointer">
        <button class="btnBask">
            <span class="frame-icon">
                <span class="icon_cleaner"></span>
    $is_logged_in = 1;
    ?>
    <?php 
    $wish_list = $CI->load->module('wishlist');
    ?>
    <?php 
    $countWL = $wish_list->getUserWishListItemsCount($CI->dx_auth->get_user_id());
} else {
    ?>
    <?php 
    $is_logged_in = 0;
    ?>
    <?php 
    $countWL = 0;
}
$cart = \Cart\BaseCart::getInstance()->getItems('SProducts');
if (count($cart['data']) > 0) {
    ?>
    <?php 
    if (is_true_array($cart['data'])) {
        foreach ($cart['data'] as $item) {
            ?>
        <?php 
            $arrCartId[] = $item->id;
            ?>
    <?php 
        }
    }
}
$countSh = getProductViewsCount();
?>