Posted: July 29, 2021 at 12:28 pm
This example demonstrates most of what I need What I want is to know how to update the table with the surcharge after the user clicks the payment type. If I refresh the page, the surcharge is shown, but I can see from other actions that the ajax request can return updated HTML. How do I return the updated table HTML? Also, can you explain how to remove the surcharge as it’s created in this example? |
|
I realized that commending out lines 44-51 (and bypassing 52) demonstrates removing the surcharge, so hopefully my understanding there is complete now. I still just need to understand how to redraw the form after choosing a payment option. Thanks |
|
Hi there, I’m a little confused but in your opening post, the hook that gist is using adds the surcharge based on the select payment method but it only does so after the payment options step has been submitted, so refreshing the page should not be showing a surcharge? We do have ajax requests redrawing some sections of the page but unless I’m misunderstanding the section you are referring to we don’t currently redraw that section. You would need your own JavaScript for this as there isn’t anything to hook into within EE to do this for you as it stands. Can you add a screenshot of the section you are looking at so I canconfirm? |
|
Pardon my abstract description without an example. I made a gist to clarify: I failed to mention that I’d switched to a different hook as well. What is working here is adding and removing the surcharge. Using the example in the gist, I only see the surcharge appear or be removed after I click the payment method and then refresh the page. What I want is to dynamically update the table #spco-payment-info-table to include the surcharge line item after clicking on a different payment method. Thanks! |
|
Before: What I’m hoping to get via ajax: |
|
Thanks for the screenshots and the gist. I checked into this and whilst technically what you are looking to do would be possible, you’d need your own ajax request for this with your own code to parse the table, return the correct section and add it into the line items table shown above. Currently, a much simpler option here is to force the page to refresh whenever the payment method is changed, which can be done with a little bit of jQuery added to your current snippet like this: |
|
Thank you. That example of loading from the frontend will suffice. I’ll use jQuery().load() to pull in just the updated cart table html. A problem arose when I moved this to the staging server. The surcharge price isn’t being passed to checkout |
|
Which payment method are you using above? Can you link me to the event so I can take a look? |
|
This reply has been marked as private. | |
Square isn’t a payment method we currently support, so may I ask how are you generating the Invoice within Square when you use the option to include a surcharge? |
|
We’re using this addon https://wpgateways.com/products/square-gateway-event-espresso/ |
|
You’ll need to contact WP Gateways and have them investigate this further. The Single Page CheckOut process generates the registrations, line items etc but once you select a payment method it’s pretty much all down to that payment method to construct the details in a way that the merchant (in this case square) can understand. So it looks like that payment method is using just the individual total and no line items details (I’m just guessing as I haven’t even seen the code for the above) but in any case, they’ll need to investigate this. |
|
The support post ‘update cart after adding surcharge’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.