06.02.2013 15:17
|
|
OldLodgeSkins
Name: Seb
13.02.2012
Posts: 18
|
Do no redirect to PayPal if amount = 0 (due to a coupon code)
Hi,
Is there a way to make it so people are not redirected to the payment page (PayPal in my case) when their order amount is equal to 0? The point is, I want people to be able to order for free when they have a coupon code.
If it only requires a small change in the code (to bypass the payment stage) and you can tell me where to do it then I'm OK with that.
Thanks.
Seb.
Joomla: 2.5.8 JoomShopping: 3.3.2 PHP: 5.3.8
|
|
06.02.2013 15:22
|
|
admin
(Support Team)
Name: Admin
05.08.2010
Posts: 25916
|
Aw: Do no redirect to PayPal if amount = 0 (due to a coupon code)
components\com_jshopping\controllers\checkout.php
function step5save(){
...
if ($jshopConfig->without_payment){
$checkout->setMaxStep(10);
$this->setRedirect(SEFLink('index.php?option=com_jshopping&controller=checkout&task=finish',0,1,$jshopConfig->use_ssl));
return 0;
}
add
if ($order->order_total==0){
$checkout->setMaxStep(10);
$this->setRedirect(SEFLink('index.php?option=com_jshopping&controller=checkout&task=finish',0,1,$jshopConfig->use_ssl));
return 0;
}
|
|
06.02.2013 15:24
|
|
OldLodgeSkins
Name: Seb
13.02.2012
Posts: 18
|
Aw: Do no redirect to PayPal if amount = 0 (due to a coupon code)
That was fast!
I'll give it a try, thank you.
|
|
06.02.2013 15:28
|
|
OldLodgeSkins
Name: Seb
13.02.2012
Posts: 18
|
Aw: Do no redirect to PayPal if amount = 0 (due to a coupon code)
Ok... I wasn't redirected to PayPal but the payment goes not finished / pending. So I guess I just need a way to validate it and it'll be working.
Oh, and the coupon didn't switch to used -> yes.
Letzte Änderung: 06.02.2013 15:31
|
|
06.02.2013 15:37
|
|
OldLodgeSkins
Name: Seb
13.02.2012
Posts: 18
|
Aw: Do no redirect to PayPal if amount = 0 (due to a coupon code)
Update - actually I think the order didn't get saved at all. The "not finished" order I was seeing is my previous test.
As for the coupon I understand better how it works, it'll deactivate itself only once all the credit there's on it has been used, right?
|
|
06.02.2013 17:38
|
|
OldLodgeSkins
Name: Seb
13.02.2012
Posts: 18
|
Aw: Do no redirect to PayPal if amount = 0 (due to a coupon code)
Ok... I'm an idiot.
I hadn't inserted your sample of code at the right place. Sorry for that!
So the situation is now that, the order IS saved - but NOT FINISHED.
So all I need now is to turn it into PAID status and I think that will be all.
Thanks again for you help.
Seb.
|
|
06.02.2013 18:20
|
|
OldLodgeSkins
Name: Seb
13.02.2012
Posts: 18
|
Aw: Do no redirect to PayPal if amount = 0 (due to a coupon code)
I have managed to change the order's status with this...
if ($order->order_total==0){
$status=6;
$checkout->changeStatusOrder($order->order_id, $status, 1);
$checkout->setMaxStep(10);
$this->setRedirect(SEFLink('index.php?option=com_jshopping&controller=checkout&task=finish',0,1,$jshopConfig->use_ssl));
return 0;
}
... Now it is "paid" but still "not finished".
I'm guessing this is the object that finishes the order at step 7:
$payment_system->finish($pmconfigs, $order, $rescode, $act);
But for now I have no idea how to use it out of that step.
Letzte Änderung: 06.02.2013 18:25
|
|
06.02.2013 18:55
|
|
OldLodgeSkins
Name: Seb
13.02.2012
Posts: 18
|
Aw: Do no redirect to PayPal if amount = 0 (due to a coupon code)
I have found a temporary solution...
$status=6;
$checkout->changeStatusOrder($order->order_id, $status, 0);
$checkout->setMaxStep(10);
$checkout->sendOrderEmail($order->order_id);
$this->setRedirect(SEFLink('index.php?option=com_jshopping&controller=checkout&task=finish',0,1,$jshopConfig->use_ssl));
return 0;
}
With this, the status switches to "paid", the e-mail is sent and the customer can download his files, even though the order is still "not finished".
It works but if you have a better solution I'm interested.
|
|
06.02.2013 19:42
|
|
admin
(Support Team)
Name: Admin
05.08.2010
Posts: 25916
|
Aw: Do no redirect to PayPal if amount = 0 (due to a coupon code)
if ($pm_method->payment_type == 1){
$order->order_created = 1;
}else {
$order->order_created = 0;
}
replace to
if ($pm_method->payment_type == 1 || $order->order_total==0){
$order->order_created = 1;
}else {
$order->order_created = 0;
}
|
|
06.02.2013 23:32
|
|
OldLodgeSkins
Name: Seb
13.02.2012
Posts: 18
|
Aw: Do no redirect to PayPal if amount = 0 (due to a coupon code)
Works perfectly!
Thanks a lot for your help! :)
|
|
19.10.2014 17:02
|
|
Jobos1
Name: J
07.10.2014
Posts: 30
|
Aw: Do no redirect to PayPal if amount = 0 (due to a coupon code)
Hello!
I would like to check if the customer uses a coupon at the checkout.
If he uses it, I want to set the payment-method select area to display: none;.
With which function or query can I check whether the customer entered a coupon code or the total order amount is 0?
Thank you!
|
|