public function calculateProduct($productObj, $qty) { if (is_object($productObj)) { if ($productObj->isTaxable()) { //if this tax rate is in the tax class associated with this product if ($productObj->getTaxClass()->taxClassContainsTaxRate($this)) { $taxCalc = $taxCalc = Config::get('vividstore.calculation'); if ($taxCalc == 'extract') { $taxrate = 10 / ($this->getTaxRate() + 100); } else { $taxrate = $this->getTaxRate() / 100; } switch ($this->getTaxBasedOn()) { case "subtotal": $productSubTotal = $productObj->getActivePrice() * $qty; $tax = $taxrate * $productSubTotal; $taxtotal = $taxtotal + $tax; break; case "grandtotal": $productSubTotal = $productObj->getActivePrice() * $qty; $shippingTotal = StorePrice::getFloat(StoreCalculator::getShippingTotal()); $taxableTotal = $productSubTotal + $shippingTotal; $tax = $taxrate * $taxableTotal; $taxtotal = $taxtotal + $tax; break; } } //if in products tax class } //if product is taxable } //if obj return $taxtotal; }
public function getShippingTotal() { $smID = $_POST['smID']; echo StorePrice::format(StoreCalculator::getShippingTotal($smID)); }
/** * @param array $data * @param StorePaymentMethod $pm * @param string $transactionReference * @param boolean $status * @return Order */ public function add($data, $pm, $transactionReference = '', $status = null) { $customer = new StoreCustomer(); $now = new \DateTime(); $smName = StoreShippingMethod::getActiveShippingMethodName(); $shippingTotal = StoreCalculator::getShippingTotal(); $taxes = StoreTax::getConcatenatedTaxStrings(); $totals = StoreCalculator::getTotals(); $total = $totals['total']; $pmName = $pm->getPaymentMethodName(); $order = new Order(); $order->setCustomerID($customer->getUserID()); $order->setOrderDate($now); $order->setPaymentMethodName($pmName); $order->setShippingMethodName($smName); $order->setShippingTotal($shippingTotal); $order->setTaxTotals($taxes['taxTotals']); $order->setTaxIncluded($taxes['taxIncludedTotal']); $order->setTaxLabels($taxes['taxLabels']); $order->setOrderTotal($total); $order->save(); $customer->setLastOrderID($order->getOrderID()); $order->updateStatus($status); $order->addCustomerAddress($customer, $order->isShippable()); $order->addOrderItems(StoreCart::getCart()); $order->createNeededAccounts(); $order->assignFilePermissions(); if (!$pm->getMethodController()->external) { $order->completeOrder($transactionReference); } return $order; }