Support

Home Forums Event Espresso Premium Where to insert code snippet?

Where to insert code snippet?

Posted: July 11, 2017 at 7:00 am

Viewing 3 reply threads


shunter06483

July 11, 2017 at 7:00 am

Where would I place the code snippet here:
https://github.com/eventespresso/ee-code-snippet-library/blob/master/checkout/bc_ee_apply_transaction_surcharge.php

and do I need to add any other code to make this work?
thanks!


Tony

  • Support Staff

July 11, 2017 at 7:12 am

Hi there,

You place that code within a custom functions plugin:

https://eventespresso.com/wiki/create-site-specific-plugin-wordpress-site/

and do I need to add any other code to make this work?

Yes, the snippet is base to work from.

At the very least you’ll need to set the correct GST_ID:

$surcharge_QST_ID = 13;

13 should be changed to match the ID of the question you are using for the surcharge.


kroskopf

July 11, 2017 at 2:20 pm

I’m also working with this snippet today.

I can add the code as a plugin and activate it. But I don’t think the code is being called soon enough to work. From the snippet…

// THE FOLLOWING CAN BE COMMENTED OUT AND THEN ADDED ANYWHERE IN YOUR SYSTEM CODE (ASSUMING THIS FILE IS LOADED)
// AS LONG AS IT IS CALLED >> BEFORE << THE WORDPRESS "pre_get_posts" HOOK AT PRIORITY 10
// THIS MEANS THAT THE ARRAY OF PRODUCTS CAN BE GENERATED DYNAMICALLY USING PRODUCT DATA FROM ANOTHER CART.
// TO UPDATE THE SYSTEM AFTER A PRODUCT IS SOLD, YOU CAN HOOK INTO THE FOLLOWING FILTER:
//      "AHEE__bc_ee_add_product_surcharge__add_product__product_added"
// WHICH IS FOUND IN THE <code>bc_ee_add_product_surcharge::add_product()</code> METHOD
new bc_ee_add_product_surcharge($products);

After I comment it out, where should I put the…

new bc_ee_add_product_surcharge($products);

Thanks!!


Josh

  • Support Staff

July 11, 2017 at 2:28 pm

The code within the .php file within the custom functions plugin loads well before the pre_get_posts hook.

Viewing 3 reply threads

The support post ‘Where to insert code snippet?’ 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