News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Cart bug (wrong redirect) when adding coupon or selecting payment/shipping

Started by SteP[IT], December 16, 2012, 12:43:38 PM

Previous topic - Next topic

SteP[IT]

Hi
I would like to notice to development team a wrong behaviour showing up in cart when taking those actions:
1) adding a coupon
2) selecting payment type
3) selecting shipment type

IMPORTANT: it happens when you configure VM2 to strictly require user registration before buying.

I'm using J 2.5.8 & VM 2.0.15d, and in my setup, when adding a coupon or selecting payment/shipment type, user is always redirected to the user login/registration page instead of being redirected back to the cart itself

This is what I get:

For the coupon issue:
a) if you add an invalid coupon, you are redirected to the login/registration page, that has at its top the error message saying "Coupon not found"
b) if you add a valid coupon, you are redirected to the login/registration page, with no message. The coupon is calculated correctly, and if you go back to the cart page using the browser back button, you see the coupon entry displayed in cart.

In my opinion, the right way to manage coupons should be this one:
a) if you add a wrong coupon, you should be redirected to the cart itself, and the error message should be placed at the top of the page, or better near the coupon field itself
b) if you add a valid coupon having no special restrictions, you should be redirected back to the cart itself.
c) if you try to add a coupon that is valid under special conditions (i.e. user or product restricted), you shold be redirected back to the cart, and also warned that you must register/login before redeeming that valid coupon: a simple general warning message in that case is confusing customer (bringing him to think that the coupon is not valid at all insetad of being informed that that coupon is vaild under certain conditions)

For payment/shipping selection issue:
If you click on the payment/shipment selection link, you go to the respective selection page. Here, you have listed the options you can choose: if you select one of them and then click on the SAVE button, you are redirected to the login/registration page. Please note that the selected option is correctly added to the cart, and if you go back using the browser back button you see them added & calculated correctlty in the cart.

This is wrong: if I stay in the cart and I'm able to select a payment/shipment, I must be redirected to the cart itself after selecting the one I like!! If you bring the customer to the login/register page, you make him confused.

I hope to have been clear enough in my explanation, and I would like to see it fixed very soon.

Waiting for you kindly reply

All the best



J 3.9.2 - VM 3.4.3

MMC EDIZIONI - Italian High-Quality PaperBooks Publisher
Site: https://www.mmcedizioni.it

Milbo

Thank you, I think I found it.
Mainly just to add a $this->_inCheckOut = false; line 744 in cart.php

private function redirecter($relUrl,$redirectMsg){

$this->_dataValidated = false;
$app = JFactory::getApplication();
if($this->_redirect ){
$this->setCartIntoSession();
$app->redirect(JRoute::_($relUrl,$this->useXHTML,$this->useSSL), $redirectMsg);
} else {
$this->_inCheckOut = false;
$this->setCartIntoSession();
return false;
}
}

Please test
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

SteP[IT]

Great: it seems to work correctly, now.
Thank you for your ultra-fast reply  ;)

ps.: ...please, keep in mind for the near future the suggested feature of adding something more specific warning message for the "wrong" coupon, in the case the coupon exists but has some restrictions that require user to be logged: now user receives a general error message, misunderstandig the fact that the coupon is NOT wrong but requires logging.
J 3.9.2 - VM 3.4.3

MMC EDIZIONI - Italian High-Quality PaperBooks Publisher
Site: https://www.mmcedizioni.it

bytelord

Yes,

is working, tried also with 2.0.15d.

btw, one more fix is been needed there is that you need to refresh the cart page when you add the coupon because is not showed and may this confuse customers, so we could add a redirect to cart page when a valid coupon is added. On the same file around line 691 add:

$app = JFactory::getApplication();
$app->redirect(JRoute::_('index.php?option=com_virtuemart&view=cart'));

the function will be:

public function setCouponCode($coupon_code) {
if (!class_exists('CouponHelper')) {
require(JPATH_VM_SITE . DS . 'helpers' . DS . 'coupon.php');
}
$prices = $this->getCartPrices();
$msg = CouponHelper::ValidateCouponCode($coupon_code, $prices['salesPrice']);
if (!empty($msg)) {
$this->couponCode = '';
$this->setCartIntoSession();
return $msg;
}
$this->couponCode = $coupon_code;
$this->setCartIntoSession();
$app = JFactory::getApplication();
$app->redirect(JRoute::_('index.php?option=com_virtuemart&view=cart'));
return '';
}


We could add a message there also like:

$app->redirect(JRoute::_('index.php?option=com_virtuemart&view=cart'), JText::_('COM_VIRTUEMART_CART_COUPON_VALID'));


This will work for 2.0.14 also, not sure for the line, please test it!

Regards
Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

SteP[IT]

Thank you too, bytelord: I confirm the coupon now works better applying your mod to the latest 2.0.15d release.
J 3.9.2 - VM 3.4.3

MMC EDIZIONI - Italian High-Quality PaperBooks Publisher
Site: https://www.mmcedizioni.it

Milbo

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/