Jump to content

[SOLVED] Down payment for cash on delivery?


Recommended Posts

I have COD installed and I want to get 20% down payment after the customer has confirmed the order. On payment choices there is field 'The total amount of your order is [total amount]. Is there any way of having this modified so that the total amount shown will be 20% of the original amount?

Basically I need a modification of the line on the code which multiplies the order amount by 20%.

Link to comment
Share on other sites

To change the total on the cash on delivery payment confirmation page, you can change the following code on line 18 of modules/cashondelivery/validation.tpl from:

{convertPrice price=$total}



to:

{convertPrice price=$total*0.2}



You could do the same on line 18 of order-payment.tpl in your theme's directory to change the total of the payment choices page.

Link to comment
Share on other sites

Thanks again! It works perfectly.

Now on the next step, order-confirmation, there are instructions for making the down payment - bank account #, company name, I would like to have the amount for 20% and order # to be shown there as well, so all the necessary details for the payment would be together but this way it doesn't work there, it displays 0 for amount and order # both.

And last question: how can I enable the cashondelivery mail to be emailed automatically to the customer after the order confirmation button has been pressed? It sends the email once the order status is manually set to COD.

Link to comment
Share on other sites

You'll need to modify the hookPaymentReturn function in modules/cashondelivery/cashondelivery.php. The $params variable contains the IDs of the order and module. I think $params[0] should get you the order ID. You can add code like the following before the return line:

$order = new Order($params[0]);
$smarty->assign('totalPaid', $order->total_paid);



This will pass the total of the order into modules/cashondelivery/confirmation.tpl.

I'm sure how to tackle the email problem. Perhaps you can add another line to the code above to send an email.

Link to comment
Share on other sites

Thanks once again!

Inserted the line:

    public function hookPayment($params)
   {
       if (!$this->active)
       $order = new Order($params[0]);
       $smarty->assign('totalPaid', $order->total_paid);
           return ;

       global $smarty;

       // Check if cart has product download
       foreach ($params['cart']->getProducts() AS $product)
       {
           $pd = ProductDownload::getIdFromIdProduct(intval($product['id_product']));
           if ($pd AND Validate::isUnsignedInt($pd))
               return false;
       }

       $smarty->assign(array(
           'this_path' => $this->_path,
           'this_path_ssl' => (Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://').htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8').__PS_BASE_URI__.'modules/'.$this->name.'/'
       ));
       return $this->display(__FILE__, 'payment.tpl');
   }



and in confirmation.tpl used this:

{convertPrice price=$total*0.2}



Where here I made the error as it is displaying just zeros for both the order # and total in confirmation page.

Link to comment
Share on other sites

In bankwire it gives me the amount $0, no errors here so the php must be on order; in cashondelivery i did put it like this:

        if (!$this->active)
           return ;

       $order = new Order($params[0]);
       $smarty->assign('totalPaid', $order->total_paid); 
       return $this->display(__FILE__, 'confirmation.tpl');



and there is an error (won't load the confirmation page at all).

Link to comment
Share on other sites

Kind worked it out myself, looks like it's working: copied a line

                'total_to_pay' => Tools::displayPrice($params['total_to_pay'], $params['currencyObj'], false, false),



and added it as

'total_to_pay' => Tools::displayPrice($params['total_to_pay'], $params['currencyObj'], false, false),

'total_to_pay_20p' => Tools::displayPrice($params['total_to_pay']*0.2, $params['currencyObj'], false, false),



Then in payment-return.tpl used the variable

{convertPrice price=$total_to_pay_20p}



Is this all right? I mean, there will be no sudden errors in the future if I keep it this way?

Link to comment
Share on other sites

  • 3 months later...
  • 1 month later...

The confirmation email is sent anyway no matter what payment was used. In the email there is the payment method mentioned already. I did put all the extra information regarding COD in that email, at the end it says like 'If you choose the COD, here is the information for you: ...'

Link to comment
Share on other sites

  • 1 month later...

Hi,

how to do to round, two numbers after point ? example:

50/3 = 16.6667 => 16.67 (or 16.66)

With :

'total_to_pay_20p' => Tools::displayPrice($params['total_to_pay']*0.2, $params['currencyObj'], false, false), 



{convertPrice price=$total_to_pay_20p} 




And them, to email could you give code to "*0.2" with :

'{total_paid}' => Tools::displayPrice($order->total_paid, $currency, false, false),
'{total_to_pay_20p}' => *0.2 ???????



I try to change in modulePayment.php:
'{total_to_pay_20p}' => Tools::displayPrice($order->total_paid *0.2, $currency, false, false),

and in modules/mailalerts.php:
'{total_to_pay_20p}' => Tools::displayPrice($order->total_paid*0.2, $currency),

In the mails/mail.html i write :

{total_to_pay_20p}

but it is not that.



Very Thanks (sorry my writing english)

Link to comment
Share on other sites

  • 11 months later...
  • 1 month later...
  • 11 months later...

hey team,

 

i have installed this cod module,

 

I was wondering if i could have one more step added into the process where the downpayment is payable immediately (with the existing payment gateways).

 

for example (as per the first post) ... ones the customer selects COD, he is taken to the order confirmation page where it shows the downpayment price.

 

on clicking next instead of confirming, it shows him the payment gateways to pay up the downpayment.

 

Any tips on this please ??

 

(if there is any paid modules to do the same i dont mind purchasing either).

 

Thanks,

R

Link to comment
Share on other sites

  • 4 months later...

Hello Everyone,

 

I need something similar to what "rahulr85r" has posted.

 

Can someone please help ?

 

Thanks,

Mohit

 

hey team,

 

i have installed this cod module,

 

I was wondering if i could have one more step added into the process where the downpayment is payable immediately (with the existing payment gateways).

 

for example (as per the first post) ... ones the customer selects COD, he is taken to the order confirmation page where it shows the downpayment price.

 

on clicking next instead of confirming, it shows him the payment gateways to pay up the downpayment.

 

Any tips on this please ??

 

(if there is any paid modules to do the same i dont mind purchasing either).

 

Thanks,

R

Link to comment
Share on other sites

  • 4 weeks later...

hey team,

 

i have installed this cod module,

 

I was wondering if i could have one more step added into the process where the downpayment is payable immediately (with the existing payment gateways).

 

for example (as per the first post) ... ones the customer selects COD, he is taken to the order confirmation page where it shows the downpayment price.

 

on clicking next instead of confirming, it shows him the payment gateways to pay up the downpayment.

 

Any tips on this please ??

 

(if there is any paid modules to do the same i dont mind purchasing either).

 

Thanks,

R

Hello Everyone,

 

I need something similar to what "rahulr85r" has posted.

 

Can someone please help ?

 

Thanks,

Mohit

 

 

I also need something similar. Help needed!

 

I'm using COD with fee v1.8

 

Thanks,

Victor

Edited by OEM+ Performance (see edit history)
Link to comment
Share on other sites

  • 6 months later...
  • 5 months later...

Hi all

new to prestashop and I need the 20% deposit as well - since it has been some time - does the solution still work or perhaps there is a better one now? I would appreciate if one of you could let me know before I start digging myself into the setup of prestashop

 

Thanks

Link to comment
Share on other sites

  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...