I am programming a module where I need to set free shipping of a quote on a certain occasions. I am trying to get this working:
$quote = Mage::helper('checkout/cart')->getCart()->getQuote();
$quote->getShippingAddress()->setFreeShipping(1);
but so far no success. Can anyone help?
EDIT: I need to do this from on the following events:
checkout_cart_update_items_after
checkout_cart_product_add_after
sales_quote_remove_item
Basically upon any cart modification I need to determine if shipping should be free of charge.
EDIT: This seems to work pretty well. Except I would need to disable free shipping as a choice in checkout.
$address = $quote->getShippingAddress();
$address->setShippingMethod('freeshipping_freeshipping');
you can first identify your event for which you want to set free shipping and based on that event you can set free shipping as your default option.
Below code might help you a bit.
app/design/frontend/default/default/template/checkout/onepage/shipping_method/available.phtml:
// find methods loop:
<?php foreach ($_rates as $_rate): ?>
// add checking for free shipping method and setting it as default
<?php if ($_rate->getCode()=='freeshipping_freeshipping' && !$this->getAddress()->getShippingMethod()) {
$this->getAddress()->setShippingMethod($_rate->getCode());
} ?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With