Jump to content

COD with fee


Recommended Posts

I have tried to set Cash On Delivery with a fee, but I do not know how it should be set properly.

 

I have installed the module Cash on delivery (COD) and I do not know how to set fee for COD.

The fee for COD will be in my case always the same value.

Thank you

Edited by jkr (see edit history)
Link to comment
Share on other sites

  • 2 months later...

I'm using 1.5.3 and the COD doesn't allow to set a fee. Which I think would be normal as it's always more expensive to ship with COD condition.

 

I'm thinking to keep it simple and just add a carrier in the backoffice which I use for COD and give also the shipment fee. But I keep it disabled.

 

Then in modules/cashondelivery/controllers/front/validation.php I want force the cart to use this carrier. So when the user selects COD as payment then it will also set the carrier to COD.

 

What is needed is these two lines to overrule the carrier. Here the 2 is the id of the carrier. So check in the backoffice which carrier you made for COD (and of course give this carrier the correct fee you like).

 

 

$this->context->cart->setDeliveryOption(array($this->context->cart->id_address_delivery=>'2,'));
$this->context->cart->update();

 

I bought some of the COD with fee modules but are really not impressed as part of the core is rewritten which I don't like and gives a risk to make mistakes or to not be able to upgrade.

 

So I'm sure to be close to a solution but it's not yet.

 

If you have coding experience then maybe this can inspire you to make it happen. If not then just wait and I might have the full solution later.

Link to comment
Share on other sites

I found a kind of solution. In modules/cashondelivery/controllers/front/validation.php within the function postProcess() I added the two lines to change the carrier JUST before processing the order. It is nicely working when the carrier is ENABLED, but I want to carrier to be disabled otherwise it will confuse the end-user as he/she can already select this carrier.

 

But so far it's working, see the lines between 'start modification' and 'end modification'

 

 

if (Tools::getValue('confirm'))
{
$customer = new Customer((int)$this->context->cart->id_customer);
// start modification
$this->context->cart->setDeliveryOption(array($this->context->cart->id_address_delivery=>'2,'));
$this->context->cart->update();
 // end modification
$total = $this->context->cart->getOrderTotal(true, Cart::BOTH);
$this->module->validateOrder((int)$this->context->cart->id, Configuration::get('PS_OS_PREPARATION'), $total, $this->module->displayName, null, array(), null, false, $customer->secure_key);
Tools::redirectLink(__PS_BASE_URI__.'order-confirmation.php?key='.$customer->secure_key.'&id_cart='.(int)$this->context->cart->id.'&id_module='.(int)$this->module->id.'&id_order='.(int)$this->module->currentOrder);
}

 

When I do a test order then it adds the carrier fee! I'm looking further to find a way to keep the carrier disables.

Link to comment
Share on other sites

×
×
  • Create New...