Follow that product removal up with a
... after having set a message to the customer via the $messageStack class (which probably will require a global $messageStack; statement) to let them know what's going on.Code:zen_redirect(zen_href_link(FILENAME_CHECKOUT_ONE));
On the page's re-display, the shipping and taxes will recalculate based on the updated products in the order.
OK, so... I'm trying to have the "shipping=billing" UNchecked by default so the customer gets to see both billing AND shipping address at the same time when going through Guest Checkout.
I've changed includes/classes/OnePageCheckout.php on line 169 from
toCode:public function getShippingBilling() { $_SESSION['shipping_billing'] = (isset($_SESSION['shipping_billing'])) ? $_SESSION['shipping_billing'] : true; return $_SESSION['shipping_billing']; }
When a customer starts checkout, both billing and shipping address fields are visible and if you fill out billing address, save it, fill out shipping address and save it, everything works fine and you can continue through checkout.Code:public function getShippingBilling() { // BOF shipping=billing default to false $_SESSION['shipping_billing'] = (isset($_SESSION['shipping_billing'])) ? $_SESSION['shipping_billing'] : false; // EOF shipping=billing default to false return $_SESSION['shipping_billing']; }
BUT, if you fill out billing details, save it and then tick the "shipping=billing" checkbox, the shipping address gets populated and properly assigned, but there's still no payment/shipping options available. Editing ANY of the details (email, billing OR shipping) and saving it bring up the shipping/payment section and allows to proceed.
What am I missing? Is this controlled anywhere else that I'm not seeing it? Thanks in advance!
I think I got it. Changing includes/classes/ajax/zcAjaxOnePageCheckout.php on line 54 seems to do the trick. I've changed it from
toCode:if ($_POST['shipping_is_billing'] == 'true') { $_SESSION['sendto'] = $_SESSION['billto']; $_SESSION['shipping_billing'] = true; $ship_to = 'billing'; $_SESSION['opc']->setTempShippingToBilling(); }
Reason for this change is because if sendto==billto, it doesn't pass validation in validateTempShiptoAddress()Code:if ($_POST['shipping_is_billing'] == 'true') { $_SESSION['sendto'] = CHECKOUT_ONE_GUEST_SENDTO_ADDRESS_BOOK_ID; $_SESSION['shipping_billing'] = true; $ship_to = 'billing'; $_SESSION['opc']->setTempShippingToBilling(); }
Initial tests indicate it's working OK, but I'm still unsure if this should be considered as an actual solution and what downsides it may have, or evn worse, what problems it may cause. Any ideas would be welcomed, especially if you can foresee any problems by using this code. Thanks!
LOL, yeah, I know, and I already have done that. The comments provided here were actually simplified or removed just to keep it simple here, but I really did try to explain it as much as I possibly could in the actual files. I've actually had to make a few other changes as well, which I was VERY unhappy with because I'd like to keep OPC as close to original as possible, primarily because you keep improving and updating it, but some things are just necessary...
BTW, you should see how I butchered the OPC's template files...
May I suggest considering adding this to a future release, with an admin-controlled switch? In some cases, it actually does make sense to show both addresses without requiring user action because billing and shipping addresses are different in 99% cases. So, if the admin could simply flip a switch to have it always shown, it would be great.
Also, one other thing I've noticed (not sure if it's been discussed before) is the inability to abort Guest Checkout and go to login. A simple scenario is - I click Guest Checkout and then I remember "oh wait, I have an account on this site, lemme login...". There's no way to go back to the point of choosing Guest-New-Returning once you start Guest Checkout, which might be a bit confusing... But then again, it's not SO important...
The issue here is that while a Billing address is always required, a Shipping address isn't (think downloads and/or Gift Certificates). That's why OPC asks initially for the billing address and gives the opportunity to indicate a different shipping address (iff one is required).
Zen Cart 1.5.7b
OPC 2.3.7-beta2 (2021-01-17)
PHP Version: 7.1.33
Shipping modules used: Storepickup, Advanced Shipper
Any suggestions as to why this message is frequently displayed when going through checkout?
"It's taking a little longer than normal to update your order's shipping cost. Please close this message and try again. If you continue to receive this message, please contact us."
Sometimes it has to be closed 2 or 3 times before you can actually complete checkout.