2

I have a script which runs through order items.

I also set up a Shopping Cart Promotional Rule for Free Shipping on certain items 'For matching items only' which I've matched by SKU in the Actions tab.

I know this rule is working because I have a custom shipping module and when calculating the shipping costs via this module the function $_item->getFreeShipping below returns 1 if the rule has applied free shipping to the item. There are no problems with this as far as I can see:

// Looping through items in checkout to calculate shipping cost to apply.
foreach ($request->getAllItems() as $_item) {
    ...
    // returns 1 for the product in question
    $_item->getFreeShipping();
    ...
}

So the above is for the items in the shipping quote.

However, after I have gone through checkout, placed the order (using Check/Money order), and invoiced the order (manually in admin panel), when I loop through the order items of the order, the $_item->getFreeShipping call is returning 0 for all items (even those that were returning 1 when calculating shipping costs)

foreach ($order->getAllItems() as $_item ) {
    ...
    // returns 0 for the product in question (and all other products)
    $_item->getFreeShipping();
    ...
}

I'm currently working with a fresh install of CE 1.7.0.2. No third party modules apart from my custom shipping module, but this only adds some custom shipping methods that calculate shipping costs based off units ordered, with some custom logic.

I need a way of getting whether the order item had free shipping when it was placed - the script is for sending an order feed to a distributor, and I need to send them the shipping cost for the order. In some cases it's more complicated than using $_order->getShippingAmount as some orders will need to be separated into separate shipments, so the effective shipping cost needs to be recalculated for each order item.

Please note for these orders I am not using the "Free Shipping" Shipping Method, just a Free Shipping Promotional Rule - might that be where the discrepancy lies?

Can anyone shed any light? Thanks in advance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.