Example #1
0
 public function loadFromCart(Cart $cart)
 {
     $shopInfo = new ShopInfo($cart->module_srl);
     $this->cart_srl = $cart->cart_srl;
     $this->module_srl = $cart->module_srl;
     $this->member_srl = $cart->member_srl;
     $this->client_name = $cart->getBillingAddress()->firstname . ' ' . $cart->getBillingAddress()->lastname;
     $this->client_email = $cart->getBillingAddress()->email;
     $this->client_company = $cart->getBillingAddress()->company;
     $this->billing_address = (string) $cart->getBillingAddress();
     $this->shipping_address = (string) $cart->getShippingAddress();
     $this->payment_method = $cart->getPaymentMethodName();
     $this->shipping_method = $cart->getShippingMethodName();
     $this->shipping_variant = $cart->getShippingMethodVariant();
     $this->shipping_cost = $cart->getShippingCost();
     $this->total = $cart->getTotal(true);
     $this->vat = $shopInfo->getVAT() ? $shopInfo->getVAT() : 0;
     $this->order_status = Order::ORDER_STATUS_PENDING;
     $this->ip = $_SERVER['REMOTE_ADDR'];
     $this->currency = $shopInfo->getCurrency();
     if ($discount = $cart->getDiscount()) {
         $this->discount_min_order = $discount->getMinValueForDiscount();
         $this->discount_type = $shopInfo->getShopDiscountType();
         $this->discount_amount = $discount->getReductionValue();
         $this->discount_tax_phase = $discount->calculateBeforeApplyingVAT() ? 'pre_taxes' : 'post_taxes';
         $this->discount_reduction_value = $discount->getReductionValue();
     }
     if ($coupon = $cart->getCoupon()) {
         $this->coupon_discount_value = $cart->getCouponDiscount();
     }
 }
Example #2
0
 public function getTotalAfterDiscountWithoutVAT()
 {
     $shop = new ShopInfo($this->module_srl);
     $discount = $this->getDiscount();
     if ($discount && ($shop->getShopDiscountType() == Discount::DISCOUNT_TYPE_FIXED_AMOUNT || $shop->getShopDiscountTaxPhase() == Discount::PHASE_AFTER_VAT)) {
         $total = $this->getTotalBeforeDiscountWithVAT();
         $total -= $discount->getReductionValue();
         return $total / (1 + $shop->getVAT() / 100);
     }
     $total = $this->getTotalBeforeDiscountWithoutVAT();
     if ($discount) {
         $total -= $discount->getReductionValue();
     }
     return $total;
 }