Display View refreshes on checkout cart quantity update

  • Posts: 163
  • Thank you received: 12
  • Hikaserial Subscription Hikashop Business
10 months 2 weeks ago #301074

-- HikaShop version -- : 4.0.0
-- Joomla version -- : 3.9.0
-- PHP version -- : 5.6.36

First, thanks for this (We avoid the shipping and payment blocks to refresh themselves when the selection is updated.) which made a world of difference.

I'm still having a minor issue with our Braintree payment plugin. When the address is updated or a new one is added during checkout, or when a product quantity is updated during checkout, the onHikashopBeforeDisplayView event is triggered. This in itself isn't a problem. But what it does is regenerate everything related to our payment method. That doesn't seem to be an issue, but since the page isn't reloaded, our JS doesn't re-initialize the payment's CC fields because it is waiting on a (document).ready.

You don't seem to be using AJAX (at least not jQuery). Is there something we can use when your block refreshes are complete as an event to start our reinitialization? I was trying to use (document).ajaxComplete, but since it doesn't seem that you're using AJAX proper (via jQuery at least) this doesn't do it.

If in fact you didn't intend to trigger the onHIkashopBeforeDisplayView event, maybe you could resolve that. Otherwise, any other solutions would be appreciated.

Thanks, Paul

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

  • Posts: 67110
  • Thank you received: 9946
  • MODERATOR
10 months 2 weeks ago #301079

Hi,

It's normal that the onHikashopBeforeDisplayView trigger is called when the payment view is refreshed.
The javascript that you add that that point will be run by the browser, even in ajax.
However, you need to display it directly if you want it to be taken into account in ajax.
If you try to use the addScriptDeclaration or addScript functions of Joomla's library, then that javascript will be missing after the refresh as the ajax system only process the javascript directly echoed by the view being refreshed.
That's partly why you can see the javascript directly added with script tags in the show_block files of the checkout view instead of using addScriptDeclaration to add it to Joomla's document element. That way, the javascript is taken into account even in ajax.

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

  • Posts: 163
  • Thank you received: 12
  • Hikaserial Subscription Hikashop Business
10 months 2 weeks ago #301110

Thanks Nicolas. I'll make those changes. Does that mean also that the addScriptOptions won't work? So I'll need to make my own AJAX call within the payment plugin to get information from Joomla to JS. Just clarifying that your comment about 'addScript functions' includes ANY activity with those functions.

Thanks, Paul

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

  • Posts: 23751
  • Thank you received: 3682
  • MODERATOR
10 months 2 weeks ago #301111

Hello,

The checkout system is made to refresh the blocks where there is a need ; when something changed.
If the modification of the billing address affect something in a payment method (make it available, change its price, or else) ; the payment block will be automatically refresh.
We are not based on jQuery since there are too many issues and conflicts to be able to use it ; we do prefer classic Javascript (also called "vanialla")
Please note that the checkout system use "events" and that is mostly how the blocks are communicating.

There is no need of "ajaxComplete" feature since the javascript within the blocks will be processed. If your payment method have some custom html with some javascript, that javascript will be processed during the refresh of the block.
Afterwards, as Nicolas explained, you can still use the addScriptDeclaration in order to push the biggest part of your JS code in the header ; then you can use the events to be notified when a checkout block is refreshed (even if I think that the best is to use the custom html to push the specific JS).

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

Time to create page: 0.060 seconds
Powered by Kunena Forum