How to catch POST variable when shipping address id change

  • Posts: 12
  • Thank you received: 0
6 years 9 months ago #288222

-- HikaShop version -- : 3.2.2
-- Joomla version -- : 3.8.5
-- PHP version -- : 7.1.6
-- Browser(s) name and version -- : Firefox 58.0.2



This is not an issue but I need to know my possibilities.

In the checkout, on the billing and shipping addresse display choice, when we change the shipping address an array of post variables is sent dinamically (by ajax I guess).
Is it possible to catch those variables in order to display dinamically something else like a list of pickup based on the address id without reload page needs ? Or should I check the cart table in the db with another ajax script to catch the current (whithout reloaded page) shipping id ?

cordially

Attachments:
Last edit: 6 years 9 months ago by skorweb.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
6 years 9 months ago #288225

Hi,

In my opinion, if you want to display a list of pickup locations so that the customer can select one among them and that this list depends on the address entered by the user, the best is to add your own checkout block via a plugin.
For that you'll want to implement the "checkout API" of HikaShop in your plugin:
www.hikashop.com/support/documentation/6...tation.html#checkout
In your plugin, you can easily load the current cart data with:
$cartClass = hikashop_get('class.cart');
$cart = $cartClass->getFullCart();
And you will have the information of the id of the selected shipping address in $cart->cart_shipping_address_ids
And you can use such code to load the details of that address:
$addressClass = hikashop_get('class.address');
$address = $addressClass->get($cart->cart_shipping_address_ids);

In your plugin, you'll want to implement onCheckoutStepList to add your new block to the list of available blocks so that you can add it to the checkout workflow in the HikaShop configuration.
You can potentially implement onBeforeCheckoutStep to check that the address has already been selected (but depending on how your checkout workflow, this might not be necessary).
You can implement onCheckoutStepDisplay to display the list based on the cart's shipping address
And you can implement onAfterCheckoutStep to save the selection of the pickup list in the cart.
What I also recommend is to configure a custom order field in order to store the selection of the pick up list.
That way, you won't have to handle the display of your selected pickup list in the order, in the email notifications, in the invoices, etc as it will be done by the custom order field system.

You can see an example of that with the plugins/hikashop/userpoints.php plugin which can add its own points usage block to the checkout in a similar way.

Please Log in or Create an account to join the conversation.

Time to create page: 0.052 seconds
Powered by Kunena Forum