Note that there are some explanatory texts on larger screens.

plurals
  1. POPass fees from one shipping method to another
    text
    copied!<p>I have a tricky shipping issue that I'm trying to work out. I have a custom extension that calculates the table rates for all of the domestic shipping. But for international, one type of product(category A) is a flat $35/product shipping fee and the rest of the products (categories B and C) are calculated by UPS and USPS. The only way I've been able to figure out how to properly calculate shipping if a customer purchases both types of products is to create a table rate for Category A, then pass it along to UPS/USPS as a handling fee. Is there a variable/method I can use for this process? I haven't yet found one.</p> <p>As requested, here's my function:</p> <pre><code>public function collectRates(Mage_Shipping_Model_Rate_Request $request) { // Cut out code where it adds up the categories and the number of items in each category $rates = $this-&gt;getRates($request, $_categories); if (!empty($rates)) { $rateTypes = array(); foreach($rates as $rate) { $rateTypes[] = $rate['method_name']; } $rateTypes = array_unique($rateTypes); $i=0; // Create array to pass along to UPS/USPS, if needed $tempCategories = $_categories; foreach($rateTypes as $rateType) { $groupPrice = 0; foreach($_categories as $category=&gt;$catQty) { $rateExists = false; $standardRate = 0; foreach($rates as $rate) { $rateCats = explode(',',$rate['category_list']); if(in_array($category,$rateCats) &amp;&amp; $rate['method_name'] == $rateType ) { $rateExists = true; if($rate['condition_type'] == 'I'){ $ratePrice = $rate['price'] * $catQty; } else if ($rate['condition_type'] == 'O') { $ratePrice = $rate['price']; } unset($tempCategories[$category]); } else if(in_array($category,$rateCats) &amp;&amp; $rate['method_name'] == "Standard" &amp;&amp; $rateType != "Standard") { if($rate['condition_type'] == 'I'){ $standardRate += $rate['price'] * $catQty; } else if ($rate['condition_type'] == 'O') { $standardRate += $rate['price']; } unset($tempCategories[$category]); } } if($rateExists == false) { $groupPrice += $standardRate; } else $groupPrice += $ratePrice; } if(count($tempCategories) &gt; 0) { // Figure out how to pass the $groupPrice to other shipping methods here } else { $method = Mage::getModel('shipping/rate_result_method'); $method-&gt;setCarrier('shippingcodes'); $method-&gt;setCarrierTitle($this-&gt;getConfigData('title')); $method-&gt;setMethod('shippingcodes_'.$rateType); $method-&gt;setMethodTitle($rateType); $method-&gt;setPrice($groupPrice); $result-&gt;append($method); } } } else return false; return $result; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload