public function view() { $this->set('cart', Session::get('cart')); $this->set('total', VividCart::getSubTotal()); $this->addHeaderItem("\n <script type=\"text/javascript\">\n var PRODUCTMODAL = '" . View::url('/productmodal') . "';\n var CARTURL = '" . View::url('/cart') . "';\n var CHECKOUTURL = '" . View::url('/checkout') . "';\n </script>\n "); $this->addFooterItem(Core::make('helper/html')->javascript('vivid-store.js', 'vivid_store')); $this->addHeaderItem(Core::make('helper/html')->css('vivid-store.css', 'vivid_store')); }
public function getCartModal() { $cart = VividCart::getCart(); $total = VividCart::getSubTotal(); if (Filesystem::exists(DIR_BASE . '/application/elements/cart_modal.php')) { View::element('cart_modal', array('cart' => $cart, 'total' => $total, 'actiondata' => $this->post())); } else { View::element('cart_modal', array('cart' => $cart, 'total' => $total, 'actiondata' => $this->post()), 'vivid_store'); } }
public function view() { $codeerror = false; $codesuccess = false; if ($this->isPost()) { if ($this->post('action') == 'code' && $this->post('code')) { $codesuccess = VividCart::storeCode($this->post('code')); $codeerror = !$codesuccess; } if ($this->post('action') == 'update') { $data = $this->post(); $result = VividCart::update($data); $added = $result['added']; $returndata = array('success' => true, 'quantity' => (int) $data['pQty'], 'action' => 'update', 'added' => $added); } if ($this->post('action') == 'clear') { VividCart::clear(); $returndata = array('success' => true, 'action' => 'clear'); } if ($this->post('action') == 'remove') { $data = $this->post(); $result = VividCart::remove($data['instance']); $returndata = array('success' => true, 'action' => 'remove'); } } $this->set('actiondata', $returndata); $this->set('codeerror', $codeerror); $this->set('codesuccess', $codesuccess); $this->set('cart', VividCart::getCart()); $this->set('discounts', VividCart::getDiscounts()); $this->set('total', VividCart::getSubTotal()); $this->addHeaderItem("\n <script type=\"text/javascript\">\n var PRODUCTMODAL = '" . View::url('/productmodal') . "';\n var CARTURL = '" . View::url('/cart') . "';\n var CHECKOUTURL = '" . View::url('/checkout') . "';\n </script>\n "); $this->requireAsset('javascript', 'vivid-store'); $this->requireAsset('css', 'vivid-store'); $discountsWithCodesExist = DiscountRule::discountsWithCodesExist(); $this->set("discountsWithCodesExist", $discountsWithCodesExist); }
public function getTotals() { $subTotal = Price::getFloat(Cart::getSubTotal()); $taxes = self::getTaxes(); $addedTaxTotal = 0; $includedTaxTotal = 0; if ($taxes) { foreach ($taxes as $tax) { if ($tax['calculation'] != 'extract') { $addedTaxTotal += $tax['taxamount']; } else { $includedTaxTotal += $tax['taxamount']; } } } $shippingTotal = Price::getFloat(Cart::getShippingTotal()); $total = $subTotal + $addedTaxTotal + $shippingTotal; return array('subTotal' => $subTotal, 'taxes' => $taxes, 'taxTotal' => $addedTaxTotal + $includedTaxTotal, 'shippingTotal' => $shippingTotal, 'total' => $total); }
public function isWithinRange() { $subtotal = VividCart::getSubTotal(); $max = $this->getMaximumAmount(); if ($max != 0) { if ($subtotal >= $this->getMinimumAmount() && $subtotal <= $this->getMaximumAmount()) { return true; } else { return false; } } elseif ($subtotal >= $this->getMinimumAmount()) { return true; } else { return false; } }
public function getTotals() { $subTotal = Cart::getSubTotal(); $taxes = Tax::getTaxes(); $addedTaxTotal = 0; $includedTaxTotal = 0; $taxCalc = Config::get('vividstore.calculation'); if ($taxes) { foreach ($taxes as $tax) { if ($taxCalc != 'extract') { $addedTaxTotal += $tax['taxamount']; } else { $includedTaxTotal += $tax['taxamount']; } } } $shippingTotal = Cart::getShippingTotal(); $discountedSubtotal = $subTotal; $discounts = self::getDiscounts(); foreach ($discounts as $discount) { if ($discount->drDeductFrom == 'subtotal') { if ($discount->drDeductType == 'value') { $discountedSubtotal -= $discount->drValue; } if ($discount->drDeductType == 'percentage') { $discountedSubtotal -= $discount->drPercentage / 100 * $discountedSubtotal; } } } $total = $discountedSubtotal + $addedTaxTotal + $shippingTotal; foreach ($discounts as $discount) { if ($discount->drDeductFrom == 'total') { if ($discount->drDeductType == 'value') { $total -= $discount->drValue; } if ($discount->drDeductType == 'percentage') { $total -= $discount->drPercentage / 100 * $total; } } } return array('subTotal' => $subTotal, 'taxes' => $taxes, 'taxTotal' => $addedTaxTotal + $includedTaxTotal, 'shippingTotal' => $shippingTotal, 'total' => $total); }
public function getSubTotal() { echo Price::format(VividCart::getSubTotal()); }
public function view() { $this->set("itemCount", VividCart::getTotalItemsInCart()); $this->set("total", Price::format(VividCart::getSubTotal())); }