Support

Home Forums Event Espresso Premium Product Surcharge

Product Surcharge

Posted: December 6, 2023 at 5:29 am


mbote

December 6, 2023 at 5:29 am

I have the below code added as a plugin to ensure that I am able to add addons to the ticket such as exhibition booths, t-Shirts, trading tables, mugs etc When I enable the plugin, when the question for exhibition booth is answered “Yes” and that for Trading table is answered “Yes”, I am able to see the price for the booth added to the ticket. However the second product, the trading table is not added at all. If I make it the only product, its added. In short only the first product is added. Kindly assist.

I have used the code from this page

Regards,
Boniface

<?php

/*
Plugin Name: EE Exhibition Booth & Trading Tables
Description: Add Exhibition Booth 
Version: 1.0
Author: mycompany
*/

$products = array(
    0 => array(
        // CHANGE NUMBER VALUE TO MATCH THE ID OF YOUR PRODUCT QUESTION
        'product_question_id'     => 23,
        // CHANGE NUMBER VALUE TO MATCH THE ID OF YOUR QUANTITY QUESTION
        'product_qty_question_id' => 24,
        // AN ARRAY THAT HOLDS DETAILS FOR EACH PRODUCT OPTION YOU ADDED AS QUESTION OPTIONS
        'product_option_details'  => array(
            // KEYS FOR THIS ARRAY SHOULD MATCH THE VALUES YOU ENTERED FOR YOUR QUESTION OPTION VALUES
            'Yes'  => array(
                'name'        => 'Exhibition Booth',
                'code'        => 'exhibition-booth',
                'description' => 'Add an Exhibition Booth for your products Display',
                'unit_price'  => 300.00,
                'taxable'     => true,
            ),
            'No' => array(
                'name'        => 'No Exhibition Booth Selected',
                'code'        => 'no-exhibition-booth',
                'unit_price'  => 0.00,
                'taxable'     => true,
            ),

            // ADD ADDITIONAL PRODUCT OPTIONS HERE
        ),
    );
 1 => array(
        // CHANGE NUMBER VALUE TO MATCH THE ID OF YOUR PRODUCT QUESTION
        'product_question_id'     => 28,
        // CHANGE NUMBER VALUE TO MATCH THE ID OF YOUR QUANTITY QUESTION
        'product_qty_question_id' => 29,
        // AN ARRAY THAT HOLDS DETAILS FOR EACH PRODUCT OPTION YOU ADDED AS QUESTION OPTIONS
        'product_option_details'  => array(
            // KEYS FOR THIS ARRAY SHOULD MATCH THE VALUES YOU ENTERED FOR YOUR QUESTION OPTION VALUES
            'Yes'  => array(
                'name'        => 'Trading Table',
                'code'        => 'trading-table',
                'description' => 'Display your wares on a table in the main hall',
                'unit_price'  => 100.00,
                'taxable'     => true,
            ),
            'No' => array(
                'name'        => 'No Table Selected',
                'code'        => 'no-trading-table',
                'unit_price'  => 0.00,
                'taxable'     => true,
            ),

            // ADD ADDITIONAL PRODUCT OPTIONS HERE
        ),
    ),
    // ADD ADDITIONAL PRODUCTS HERE
);


Tony

  • Support Staff

December 7, 2023 at 8:56 am

Hi Boniface,

Is that the actual code you are using right now? The majority of the function is missing so I assume you’ve just included the $products array here….

However, the array is closed here:

    ); <<<
 1 => array(

This means you only have 1 element in the array but I’d also expect that code to throw a syntax error if that was the case, that ; needs to be a ,.

I’ve tested this with the above snippet and I’m getting the same results so I’ve asked one of our developers for some feedback.

Side note, there is a 3rd party add-on available for this which provides a UI to do the above here:

https://aparnascodex.com/downloads/price-modifier-for-event-espresso-4/


Brent Christensen

  • Support Staff

December 7, 2023 at 1:21 pm

Hi mbote,

I’m Event Espresso’s lead developer. I’ve updated the code for the bc_ee_add_product_surcharge so that it now correctly adds more than one product.

Keep your products array as is, but update the rest of the code from that snippet.

Please let us know if that works.

The support post ‘Product 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