Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I was creating a complex shipping method...rather than a copy of the free shipping method. Turns out i actually needed a copy of the free shipping method, so made my life easier... This was easier than i thought it would be.</p> <p>Dont want to post all my code (you will also need a config.xml and system.xml file) but heres my carrier model logic file:</p> <pre><code>class Myco_Clickcollectshipping_Model_Carrier_Mymethod extends Mage_Shipping_Model_Carrier_Abstract { protected $_code = 'mymethod '; public function collectRates(Mage_Shipping_Model_Rate_Request $request) { if (!$this-&gt;getConfigFlag('active')) { return false; } $freeBoxes = 0; if ($request-&gt;getAllItems()) { foreach ($request-&gt;getAllItems() as $item) { if ($item-&gt;getFreeShipping() &amp;&amp; !$item-&gt;getProduct()-&gt;isVirtual()) { $freeBoxes+=$item-&gt;getQty(); } } } $this-&gt;setFreeBoxes($freeBoxes); $result = Mage::getModel('shipping/rate_result'); if ($this-&gt;getConfigData('type') == 'O') { // per order $shippingPrice = $this-&gt;getConfigData('price'); } elseif ($this-&gt;getConfigData('type') == 'I') { // per item $shippingPrice = ($request-&gt;getPackageQty() * $this-&gt;getConfigData('price')) - ($this-&gt;getFreeBoxes() * $this-&gt;getConfigData('price')); } else { $shippingPrice = false; } $shippingPrice = $this-&gt;getFinalPriceWithHandlingFee($shippingPrice); if ($shippingPrice !== false) { $method = Mage::getModel('shipping/rate_result_method'); $method-&gt;setCarrier('mymethod '); $method-&gt;setCarrierTitle($this-&gt;getConfigData('title')); $method-&gt;setMethod('mymethod '); $method-&gt;setMethodTitle($this-&gt;getConfigData('name')); if ($request-&gt;getFreeShipping() === true || $request-&gt;getPackageQty() == $this-&gt;getFreeBoxes()) { $shippingPrice = '0.00'; } $method-&gt;setPrice($shippingPrice); $method-&gt;setCost($shippingPrice); $result-&gt;append($method); } return $result; } public function getAllowedMethods() { return array('mymethod ' =&gt; $this-&gt;getConfigData('name')); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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