/** * @param array $data * @param Mage_Sales_Model_Quote|Mage_Sales_Model_Order $object */ private function _fillCartInformation(&$data, $object) { $productIids = array(); $productQtys = array(); $productStyleIds = array(); /** @var Mage_Sales_Model_Quote_Item|Mage_Sales_Model_Order_Item $item */ foreach ($object->getAllVisibleItems() as $item) { $productIids[] = $item->getProduct()->getIid(); $productQtys[] = is_null($item->getQtyOrdered()) ? (int) $item->getQty() : (int) $item->getQtyOrdered(); $productStyleIds[] = $item->getProduct()->getNumber() . '-' . $item->getProduct()->getColorCode(); } $data['productStyleId'] = implode(',', $productStyleIds); $data['cartProductIds'] = implode(',', $productIids); $data['cartProductQtys'] = implode(',', $productQtys); $data['cartTotalNetto'] = round($object->getBaseSubtotal(), 2); $data['cartTotalBrutto'] = round($object->getBaseGrandTotal(), 2); $data['customerId'] = (int) $object->getCustomerId(); // For zanox tracking if (array_key_exists('zanpid', $_COOKIE) && $_COOKIE['zanpid'] != '') { $data['zanpid'] = $_COOKIE['zanpid']; } }
/** * Check whether payment method is applicable to quote * Purposed to allow use in controllers some logic that was implemented in blocks only before * * @param Mage_Sales_Model_Quote $quote * @param int|null $checksBitMask * @return bool */ public function isApplicableToQuote($quote, $checksBitMask) { if ($checksBitMask & self::CHECK_USE_FOR_COUNTRY) { if (!$this->canUseForCountry($quote->getBillingAddress()->getCountry())) { return false; } } if ($checksBitMask & self::CHECK_USE_FOR_CURRENCY) { if (!$this->canUseForCurrency($quote->getStore()->getBaseCurrencyCode())) { return false; } } if ($checksBitMask & self::CHECK_USE_CHECKOUT) { if (!$this->canUseCheckout()) { return false; } } if ($checksBitMask & self::CHECK_USE_FOR_MULTISHIPPING) { if (!$this->canUseForMultishipping()) { return false; } } if ($checksBitMask & self::CHECK_USE_INTERNAL) { if (!$this->canUseInternal()) { return false; } } if ($checksBitMask & self::CHECK_ORDER_TOTAL_MIN_MAX) { $total = $quote->getBaseGrandTotal(); $minTotal = $this->getConfigData('min_order_total'); $maxTotal = $this->getConfigData('max_order_total'); if (!empty($minTotal) && $total < $minTotal || !empty($maxTotal) && $total > $maxTotal) { return false; } } if ($checksBitMask & self::CHECK_RECURRING_PROFILES) { if (!$this->canManageRecurringProfiles() && $quote->hasRecurringItems()) { return false; } } if ($checksBitMask & self::CHECK_ZERO_TOTAL) { $total = $quote->getBaseSubtotal() + $quote->getShippingAddress()->getBaseShippingAmount(); if ($total < 0.0001 && $this->getCode() != 'free' && !($this->canManageRecurringProfiles() && $quote->hasRecurringItems())) { return false; } } return true; }
/** * Build Amount * * @param Mage_Sales_Model_Quote $quote * @return Amount */ protected function buildAmount($quote) { $details = new Details(); $details->setShipping($quote->getShippingAddress()->getBaseShippingAmount())->setTax($quote->getBillingAddress()->getBaseTaxAmount() + $quote->getBillingAddress()->getBaseHiddenTaxAmount() + $quote->getShippingAddress()->getBaseTaxAmount() + $quote->getShippingAddress()->getBaseHiddenTaxAmount())->setSubtotal($quote->getBaseSubtotal()); $totals = $quote->getTotals(); if (isset($totals['discount']) && $totals['discount']->getValue()) { $details->setShippingDiscount(-$totals['discount']->getValue()); } $amount = new Amount(); $amount->setCurrency($quote->getBaseCurrencyCode())->setDetails($details)->setTotal($quote->getBaseGrandTotal()); return $amount; }