Support

Home Forums Event Espresso Premium update cart after adding surcharge

update cart after adding surcharge

Posted: July 29, 2021 at 12:28 pm

Viewing 11 reply threads


careertraining

July 29, 2021 at 12:28 pm

This example demonstrates most of what I need
https://github.com/eventespresso/ee-code-snippet-library/blob/master/checkout/bc_add_cart_modifier.php

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?


careertraining

July 30, 2021 at 12:19 pm

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


Tony

  • Support Staff

August 3, 2021 at 9:55 am

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?


careertraining

August 3, 2021 at 12:44 pm

Pardon my abstract description without an example. I made a gist to clarify:
https://gist.github.com/g000m/dc42d693f236507c2733982c577a416f

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!


careertraining

August 3, 2021 at 12:56 pm

Before:
before clicking 'credit card' and reloading

What I’m hoping to get via ajax:


Tony

  • Support Staff

August 9, 2021 at 7:19 am

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:

https://gist.github.com/Pebblo/54bde348a4981e3ea15575bc366c1b5f#file-bc_add_cart_modifier-php-L71-L82


careertraining

August 20, 2021 at 1:27 pm

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
Surcharge amount missing from payment screen


Tony

  • Support Staff

August 23, 2021 at 6:08 am

Which payment method are you using above?

Can you link me to the event so I can take a look?


careertraining

August 25, 2021 at 4:54 pm

This reply has been marked as private.


Tony

  • Support Staff

August 26, 2021 at 7:47 am

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?


careertraining

August 30, 2021 at 3:02 pm

We’re using this addon https://wpgateways.com/products/square-gateway-event-espresso/


Tony

  • Support Staff

August 31, 2021 at 12:19 pm

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.

Viewing 11 reply threads

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.

Event Espresso