将Woocommerce产品插件字段添加到EventOn票证

时间:2017-02-09 07:51:31

标签: php wordpress woocommerce

我使用名为EventOn Tickets的Wordpress插件提供购票。 Woocommerce Addon Fields显示在常规产品上,但不显示在EventOn票证上。我正在寻找帮助,将Woocommerce Addon Fields添加到Eventon Tickets checkout并正常运行。

此问题代码仅显示"添加到购物车"数量按钮。使用标准的Woocommerce变量产品它可以工作但不允许我按照我的意愿显示选项,我喜欢使用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 个答案:

答案 0 :(得分:1)

产品插件显示在woocommerce_before_add_to_cart_button挂钩上(请参阅Product_Addon_Display类的构造函数)。因此,只要您有一个do_action( 'woocommerce_before_add_to_cart_button' );动作挂钩,就应该显示插件。

确保您的表单具有标准的WooCommerce挂钩将有助于它支持更多WooCommerce扩展。

<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' ); ?>