Esempio n. 1
0
 /**
  * Make sure caches are empty
  * Must be called before calling multiple time getContextualValue()
  */
 public static function cleanCache()
 {
     self::$only_one_gift = array();
 }
 $showPopup = $coupon->getShowPopup();
 $showBanner = $coupon->getShowBanner();
 $sendEmail = $coupon->getSendEmail();
 $scShopId = $coupon->getScShopId();
 $minimalCartValue = $coupon->getMinCart();
 //JEŚLI JEST KOD W SHOPCONNECTOR - TO SPRAWDZ CZY JEST JUZ W SYSTEMIE SKLEPU
 if (!empty($discountName)) {
     $discountValue = (string) $coupon->getDiscountType();
     $discount = new CartRuleCore(intval(CartRuleCore::getIdByCode($discountName)));
     //PRESTA CODE
     //JEŚLI KOD NIE ISTNIEJE W SKLEPIE TO DODAJEMY GO, DZIĘKI TEMU MOŻE GO WYKORZYSTAĆ KLIENT
     if (is_object($discount) and !$discount->id) {
         //PRESTA CODE
         if ($couponData === true) {
             try {
                 $object = new CartRuleCore();
                 $object->id_customer = 0;
                 $object->id_currency = 0;
                 $object->id_discount_type = 1;
                 $object->name = 'Discount from shopconnector: $discountName';
                 $object->code = $discountName;
                 $object->description = "Discount from partner site {$discountName}";
                 $object->reduction_percent = $discountValue;
                 $object->quantity = 1;
                 $object->quantity_per_user = 1;
                 $object->cumulable = false;
                 $object->cumulable_reduction = false;
                 $object->date_from = date("Y-m-d");
                 $object->date_to = date("Y-m-d", time() + 3600 * 24 * 365);
                 $object->minimum_amount = floatval($minimalCartValue);
                 $object->minimum_amount_tax = true;