Question

I need a solution to a problem that I've been struggling with for some time now.

I need some sort of shipping rule that changes price dependent on the END of an SKU.

For example, if a SKU ended xxxx-TICK it would be charged at £5.00, where as a SKU ending in xxxx-PHYS would be charged at £10.00.

I've not come across any post or plugin that could solve this.

I'm open to all ideas!!

Was it helpful?

Solution

You can achieve this by modifying your carrier model class's collectRates() method. Here, in this method you can check if the quote item has a product whose SKU ends with either 'TICK' or 'PHYS' and set $shippingPrice with the respective value.

$quote = Mage::getSingleton('checkout/session')->getQuote();

$cartItems = $quote->getAllVisibleItems();


foreach ($cartItems as $item) {
    $product = $item->getProduct();
    $sku = $product->getSku();

    //your logic to compare the sku
    //for example
    if('sku ends with TICK'){
        $shippingPrice += 5; 
    }

    if('sku ends with PHYS'){
        $shippingPrice += 10; 
    }
}

Hope this helps. If you have any doubts please feel free to ask me further. Thanks.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top