Posted: January 2, 2019 at 6:44 pm
|
Hi, We’re needing to add an extra amount to the cart if a specific type of ticket is in the cart. There are two ways I can see this being able to happen: Using a coupon code or getting the cart total and adding the amount. I think option one is the best option – since it’s using the most existing code the part I’m having trouble getting working is checking if a ticket is in the cart. I haven’t found it in the documentation and was wondering if you can provides some pointers. Thanks |
|
Hi, We are needing to have add an amount if a ticket is selected, here’s an example: If either ticket type one or two is added to the cart (any quantity/combination) we need to add an extra $50. What’s the best way to do this? Thanks, Cameron Gilroy |
|
Hi, We are needing to have add an amount if a ticket is selected, here’s an example: If either ticket type one or two is added to the cart (any quantity/combination) we need to add an extra $50. What’s the best way to do this? Thanks, Cameron Gilroy PS I’m not sure if it’s been posted – I can’t see it anywhere in the forums. |
Hi there,
Currently, promotions cannot be surcharges so I’m not sure how this would work? Unless your adding your own promotion type?
How are you going to change the price within the cart? Adding a line item? Whilst checking for a ticket is the first thing you’re going to need to do (in multiple locations), if you don’t have the above worked out with some kind of plan you’re going to struggle. So are you adding your own promotion to the promotion system to accommodate #1 and have you stepped through to see how EE builds out the transaction line items so that you can add your own to discount the total (which you’ll likely need to do regardless of the method you use)? |
|
|
Hi Tony, I was thinking of using this code from GitHub (https://github.com/eventespresso/ee-code-snippet-library/blob/master/checkout/bc_ee_apply_transaction_surcharge.php) but I’m not sure on the best way to change it from looping through form fields to checking what kind of tickets are in the basket. Thanks, Cameron Gilroy |
That code applies really late, its after the user has added the tickets to their cart and also possibly visited the cart first, then added attendee information and stepped through to the payment options, only then would that snippet show a surcharge, is that not too late? I would have thought you’d need to hook into the cart itself and the ajax request made to add/remove tickets to and from the cart to run the code as the tickets are added so you know when/if the ticket in question is added/removed. It also seems similar to the likes of prechecked cart items that add additional fees onto the checkout process (which are frowned up and depending on your location may not actually be legal) as your showing one price at the beginning of the checkout then seemingly randomly (to the user) adding on a surcharge based on the ticket. |
|
|
Thanks for the reply Tony, the extra cost is clearly outlined. If I’m checking the ticket is added and if it is then add another ticket for the amount that’s needed.
|
I checked and couldn’t find any that would help with this, the place would recommend looking is in the Multi-Event Registration add-on itself. There are some examples of adding surcharges to the checkout process in our snippet library here: https://github.com/eventespresso/ee-code-snippet-library/tree/master/checkout But you’ve already linked to one of those so I’m assuming you’ve already checked those.
I don’t know any anyone that has done this/some similar before so I don’t think you’ll find anything similar to use as a base. Pulling the tickets is actually the easiest part of the above, if you have the EE_Checkout object from the cart, you have an EE_Transaction object and if you have an EE_Transaction object you can do:
Now you have an array of EE_Registrations linked to an EE_Ticket so you can pull/compare the names/ID/whatever for that ticket easily from there. Heres an example of pulling the registrations from the current checkout and looping over them: https://gist.github.com/Pebblo/f4561461339c59411a849f93c91912a9 Your will be slightly different as you’ll use the ticket from a registration but the way in which you can pull them is the same. |
|
The support post ‘Apply amount to cart if a ticket is in the cart’ 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.