/**
  * Generate the module
  */
 protected function compile()
 {
     $objCart = Isotope::getCart();
     $objAddress = $objCart->getShippingAddress();
     $this->Template->showResults = false;
     $this->Template->requiresShipping = false;
     // There is no address
     if (!$objAddress->id) {
         return;
     }
     $this->Template->showResults = true;
     $arrMethods = array();
     // Get the shipping methods
     if ($objAddress->id && $objCart->requiresShipping()) {
         $this->Template->requiresShipping = true;
         $objShippingMethods = Shipping::findMultipleByIds($this->arrShippingMethods);
         /* @var Shipping $objShipping */
         foreach ($objShippingMethods as $objShipping) {
             if ($objShipping->isAvailable()) {
                 $fltPrice = $objShipping->getPrice();
                 $arrMethods[] = array('label' => $objShipping->getLabel(), 'price' => $fltPrice, 'formatted_price' => Isotope::formatPriceWithCurrency($fltPrice), 'shipping' => $objShipping);
             }
         }
         RowClass::withKey('rowClass')->addCount('row_')->addFirstLast('row_')->addEvenOdd('row_')->applyTo($arrMethods);
     }
     $this->Template->shippingMethods = $arrMethods;
 }
예제 #2
0
파일: Group.php 프로젝트: Aziz-JH/core
 /**
  * Get shipping methods for this group
  * Must be lazy-loaded to prevent recursion
  * @return  array
  */
 protected function getGroupMethods()
 {
     if (false === $this->arrMethods) {
         $this->arrMethods = array();
         $arrMethods = deserialize($this->group_methods, true);
         // Prevent recursion if we should load ourselves
         if (($key = array_search($this->id, $arrMethods)) !== false) {
             unset($arrMethods[$key]);
         }
         if (($objMethods = Shipping::findMultipleByIds($arrMethods)) !== null) {
             foreach ($objMethods as $objMethod) {
                 if ($objMethod->isAvailable()) {
                     $this->arrMethods[] = $objMethod;
                 }
             }
         }
     }
     return $this->arrMethods;
 }