1
votes

I'm using a Wordpress plugin called EventOn Tickets which offers ticket purchases. Woocommerce Addon Fields display on regular products but not on the EventOn tickets. I'm looking for help to have the Woocommerce Addon Fields added to the Eventon Tickets checkout and be functional.

Here is the problem code that only displays the "Add to Cart" button with a quantity. Using standard Woocommerce Variable Products it works but that doesn't allow me to display the options as I would like and I like the data entry with Woocommerce Product Addons.

<p itemprop="price" class="price tx_price_line"><?php echo eventon_get_custom_language($opt, 'evoTX_002ff','Price').': '. $product->get_price_html(); ?></p>
<form class='tx_orderonline_single' data-producttype='single' method="post" enctype='multipart/form-data'>
<div class='tx_orderonline_add_cart'>
<?php
    // calculate correct max capacity
    $max_quantity = ($capacity_of_this_repeat!='none') ? $capacity_of_this_repeat: 
        ($product->backorders_allowed() ? '' : $product->get_stock_quantity());
        if ( ! $product->is_sold_individually() )
            woocommerce_quantity_input( array(
            'min_value' => apply_filters( 'woocommerce_quantity_input_min', 1, $product ),
                'max_value' => apply_filters( 'woocommerce_quantity_input_max', $max_quantity, $product )
            ), $product );
    ?>
    <input type="hidden" name="add-to-cart" value="<?php echo esc_attr( $product->id ); ?>" />
    <button data-product_id='<?php echo $woo_product_id;?>' id='cart_btn' class="evoAddToCart evcal_btn single_add_to_cart_button button alt"><?php echo apply_filters('single_add_to_cart_text', eventon_get_custom_language($opt, 'evoTX_002','Add to Cart'), $product->product_type); ?></button>
    <div class="clear"></div>
</div>
</form>
1

1 Answers

1
votes

Product addons are displayed on the woocommerce_before_add_to_cart_button hook (see the constructor of the Product_Addon_Display class). So as long as you have a do_action( 'woocommerce_before_add_to_cart_button' ); action hook then the addons should display.

Making sure that your form has the standard WooCommerce hooks will help it support more WooCommerce extensions.

<p itemprop="price" class="price tx_price_line"><?php echo eventon_get_custom_language($opt, 'evoTX_002ff','Price').': '. $product->get_price_html(); ?></p>

<?php do_action( 'woocommerce_before_add_to_cart_form' ); ?>

<form class='tx_orderonline_single' data-producttype='single' method="post" enctype='multipart/form-data'>
<div class='tx_orderonline_add_cart'>
<?php
    // calculate correct max capacity
    $max_quantity = ($capacity_of_this_repeat!='none') ? $capacity_of_this_repeat: 
        ($product->backorders_allowed() ? '' : $product->get_stock_quantity());
        if ( ! $product->is_sold_individually() )
            woocommerce_quantity_input( array(
            'min_value' => apply_filters( 'woocommerce_quantity_input_min', 1, $product ),
                'max_value' => apply_filters( 'woocommerce_quantity_input_max', $max_quantity, $product )
            ), $product );
    ?>
    <input type="hidden" name="add-to-cart" value="<?php echo esc_attr( $product->id ); ?>" />

    <?php do_action( 'woocommerce_before_add_to_cart_button' );  ?>
    <button data-product_id='<?php echo $woo_product_id;?>' id='cart_btn' class="evoAddToCart evcal_btn single_add_to_cart_button button alt"><?php echo apply_filters('single_add_to_cart_text', eventon_get_custom_language($opt, 'evoTX_002','Add to Cart'), $product->product_type); ?></button>

    <?php do_action( 'woocommerce_after_add_to_cart_button' ); ?>
    <div class="clear"></div>
</div>
</form>

<?php do_action( 'woocommerce_after_add_to_cart_form' ); ?>