Ejemplo n.º 1
0
">
                        <?php 
    echo JText::_($item->shipping_method_name);
    ?>
                    </a>
                    <div class="shipping_rates">
                      	<?php 
    $id = JFactory::getApplication()->input->getInt('id', '0');
    ?>
                        <span style="float: right;">
                        [<?php 
    echo J2StorePopup::popup("index.php?option=com_j2store&view=shipping&task=view&id={$id}&shippingTask=setRates&tmpl=component&sid={$item->j2store_shippingmethod_id}", JText::_('J2STORE_SHIPM_SET_RATES'));
    ?>
                      	 ]</span>
                        <?php 
    if ($shipping_method_type = J2StoreShipping::getType($item->shipping_method_type)) {
        echo "<b>" . JText::_('J2STORE_STANDARD_SHIPPING_TYPE') . "</b>: " . JText::_($shipping_method_type->title);
    }
    if ($item->subtotal_minimum > '0') {
        echo "<br/><b>" . JText::_('J2STORE_SHIPPING_METHODS_MINIMUM_SUBTOTAL_REQUIRED') . "</b>: " . J2Store::currency()->format($item->subtotal_minimum);
    }
    if ($item->subtotal_maximum > '-1') {
        echo "<br/><b>" . JText::_('J2STORE_SHIPPING_METHODS_SUBTOTAL_MAX') . "</b>: " . J2Store::currency()->format($item->subtotal_maximum);
    }
    ?>
                    </div>
				</td>
				<td style="text-align: center;">
				    <?php 
    echo $item->taxprofile_name;
    ?>
Ejemplo n.º 2
0
 /**
  * Generates shipping method type list
  *
  * @param string The value of the HTML name attribute
  * @param string Additional HTML attributes for the <select> tag
  * @param mixed The key that is selected
  * @returns string HTML for the radio list
  */
 public static function shippingtype($selected, $name = 'filter_shipping_method_type', $attribs = array('class' => 'inputbox'), $idtag = null, $allowAny = false, $title = 'J2STORE_SELECT_SHIPPING_TYPE')
 {
     $list = array();
     if ($allowAny) {
         $list[] = self::option('', "- " . JText::_($title) . " -");
     }
     require_once JPATH_ADMINISTRATOR . '/components/com_j2store/library/shipping.php';
     $items = J2StoreShipping::getTypes();
     foreach ($items as $item) {
         $list[] = JHTML::_('select.option', $item->id, $item->title);
     }
     return self::genericlist($list, $name, $attribs, 'value', 'text', $selected, $idtag);
 }
Ejemplo n.º 3
0
 public function getTotal($shipping_method_id, $orderItems)
 {
     $doc = JFactory::getDocument();
     $return = new JObject();
     $return->shipping_rate_id = '0';
     $return->shipping_rate_price = '0.00000';
     $return->shipping_rate_handling = '0.00000';
     $rate_exists = false;
     // cast product_id as an array
     $orderItems = (array) $orderItems;
     // determine the shipping method type
     JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_j2store' . DS . 'tables');
     $shippingmethod = JTable::getInstance('ShippingMethods', 'Table');
     $shippingmethod->load($shipping_method_id);
     if (empty($shippingmethod->id)) {
         // TODO if this is an object, setError, otherwise return false, or 0.000?
         $return->setError(JText::_("Undefined Shipping Method"));
         return $return;
     }
     switch ($shippingmethod->shipping_method_type) {
         case "2":
             // 5 = per order - price based
             // Get the total of the order, and find the rate for that
             $total = 0;
             foreach ($orderItems as $item) {
                 $total += $item->orderitem_final_price;
             }
             JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_j2store' . DS . 'models');
             $model = JModelLegacy::getInstance('ShippingRates', 'J2StoreModel');
             $model->setState('filter_shippingmethod', $shipping_method_id);
             $model->setState('filter_weight', $total);
             // Use weight as total
             $items = $model->getList();
             if (empty($items)) {
                 return JTable::getInstance('ShippingRates', 'Table');
             }
             $rate = $items[0];
             // if $rate->shipping_rate_id is empty, then no real rate was found
             if (!empty($rate->shipping_rate_id)) {
                 $rate_exists = true;
             }
             break;
         case "1":
             // 1 = per order - quantity based
             // first, get the total quantity of shippable items for the entire order
             // then, figure out the rate for this number of items (use the weight range field) + geozone
         // 1 = per order - quantity based
         // first, get the total quantity of shippable items for the entire order
         // then, figure out the rate for this number of items (use the weight range field) + geozone
         case "0":
             // 0 = per order - flat rate
             // if any of the products in the order require shipping
             $count_shipped_items = 0;
             $order_ships = false;
             foreach ($orderItems as $item) {
                 // find out if the order ships
                 // and while looping through, sum the weight of all shippable products in the order
                 $pid = $item->product_id;
                 require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_j2store' . DS . 'library' . DS . 'j2item.php';
                 $product_helper = new J2StoreItem();
                 $isShips = $product_helper->isShippingEnabled($pid);
                 if (!empty($isShips)) {
                     $product_id = $item->product_id;
                     $order_ships = true;
                     $count_shipped_items += $item->orderitem_quantity;
                 }
             }
             if ($order_ships) {
                 switch ($shippingmethod->shipping_method_type) {
                     case "1":
                         // quantity //based get the shipping rate for the entire order using the count of all products in the order that ship
                         $rate = $this->getRate($shipping_method_id, $product_id, '1', $count_shipped_items);
                         break;
                     default:
                     case "0":
                         // flat rate // don't use weight, just do flat rate for entire order
                         // regardless of weight and regardless of the number of items
                         $rate = $this->getRate($shipping_method_id, $product_id);
                         break;
                 }
                 // if $rate->shipping_rate_id is empty, then no real rate was found
                 if (!empty($rate->shipping_rate_id)) {
                     $rate_exists = true;
                 }
             }
             break;
         default:
             //	throw new Exception(JText::_( "Invalid Shipping Method Type" ));
             return false;
             break;
     }
     if (!$rate_exists) {
         //	throw new Exception( JText::_( "No Rate Found" ) );
         return false;
     }
     $shipping_tax_rates = array();
     $shipping_method_price = 0;
     $shipping_method_handling = 0;
     $shipping_method_tax_total = 0;
     // now calc for the entire method
     /*
     foreach ($geozone_rates as $geozone_id=>$geozone_rate_array)
     {
     foreach ($geozone_rate_array as $geozone_rate)
     {
     $shipping_method_price += ($geozone_rate->shipping_rate_price * $geozone_rate->qty);
     $shipping_method_handling += $geozone_rate->shipping_rate_handling;
     
     }
     }
     */
     // return formatted object
     //   print_r($rate);
     $return->shipping_method_price = $rate->shipping_rate_price;
     $return->shipping_method_handling = $rate->shipping_rate_handling;
     $return->shipping_method_total = $rate->shipping_rate_price + $rate->shipping_rate_handling;
     $return->shipping_method_id = $shipping_method_id;
     $return->shipping_method_name = J2StoreShipping::getShippingName($shipping_method_id);
     return $return;
 }