/** * @param \Syscover\ShoppingCart\Cart $shoppingCart * @param string $couponCode * @param string $lang add coupon code from this language * @param \Illuminate\Auth\SessionGuard $sessionGuard request session guard to check if user is authenticated, for cases necessary * @return null | \Syscover\Market\Models\CartPriceRule */ public static function addCouponCode($shoppingCart, $couponCode, $lang, $sessionGuard = null) { $response = CouponLibrary::checkCouponCode($couponCode, $lang, $sessionGuard); $cartPriceRule = null; // check that rule its ok if ($response['status'] == 'success') { // get price rule from database $cartPriceRule = CartPriceRule::builder($lang)->where('coupon_code_120', 'like', $couponCode)->first(); if ($cartPriceRule != null) { try { $shoppingCart->addCartPriceRule(new PriceRule($cartPriceRule->name_text_value, $cartPriceRule->description_text_value, $cartPriceRule->discount_type_id_120, $cartPriceRule->free_shipping_120, $cartPriceRule->discount_fixed_amount_120, $cartPriceRule->discount_percentage_120, $cartPriceRule->maximum_discount_amount_120, $cartPriceRule->apply_shipping_amount_120, $cartPriceRule->combinable_120, ['priceRule' => $cartPriceRule])); } catch (ShoppingCartNotCombinablePriceRuleException $e) { dd($e->getMessage()); } catch (\Exception $e) { dd($e->getMessage()); } } else { dd("this coupon number not exist"); } } return $cartPriceRule; }
public static function getTranslationRecord($parameters) { $cartPriceRule = CartPriceRule::builder($parameters['lang'])->where('id_120', $parameters['id'])->first(); return $cartPriceRule; }