Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Conditional Script Loading In Checkout Rate Topic   - - - - -

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 12075 posts

Posted 03 April 2021 - 10:11 PM #1

I have a payment method that needs to load a

<script src="blahblah"....

I have it setup as

<script class="cm-ajax-force" data-no-defer src="blahblah"...

I have this inside of a div that is loaded when a payment processor is selected (other than the default).

However, the script tag is never loaded unless the page is refreshed when the payment method is selected.

The core is removing this tag and I need to know how to have it NOT do so.  

 

I had hoped the combination of class="cm-ajax-force" and data-no-defer would have had cs-cart leave this alone.

 

Is there an attribute or micro-class I can use to have it left alone?

 

I'd just load it at the top except that I need to look at the processor_params to see if it's production or sandbox mode to load the appropriate script. src.

 

Any help is greatly appreciated.  With scripts, there's so much that goes on behind the scenes, it's hard to keep track of.


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 12075 posts

Posted 04 April 2021 - 07:29 PM #2

Looks like this is being cached by the js/tygh/ajax.js and is using an internal 'promise' mechanism.

I'm not a JS expert by any means.  But I need to be able to prevent caching and (I'm assuming) it's adding a parameter to the end of the URL.  The script is self-checking an if it's not from an exact 'src=' that it expects, it will not allow execution.  Not clear why refreshing the page and having it load outside of the ajax request allows it to work properly.

 

I've  tried using $.getScript() but that is also overridden in tygh/ajax.js.  So I'm outside of my experience if anyone can help.  Possibly someone from cs-cart might chime in?


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.