【问题标题】:Add Woocommerce Product Addon Fields to EventOn Tickets将 Woocommerce 产品插件字段添加到 EventOn 门票
【发布时间】:2017-02-09 07:51:30
【问题描述】:

我正在使用一个名为 EventOn Tickets 的 Wordpress 插件,它提供购票服务。 Woocommerce 插件字段显示在常规产品上,但不在 EventOn 门票上。我正在寻求帮助,以将 Woocommerce 插件字段添加到 Eventon 门票结账并发挥作用。

这是仅显示带有数量的“添加到购物车”按钮的问题代码。使用标准的 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>
<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>

【问题讨论】:

    标签: php wordpress woocommerce


    【解决方案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' ); ?>
    

    【讨论】:

    • 非常感谢您的反馈。做研究是的,看起来 woocommerce_before_add_to_cart_button 应该添加该功能。我使用了您的代码,令人惊讶的是,页面上显示了完全相同的输出。我添加了一些额外的文本以确认它确实在使用该代码。我还将表单前的 do_action 更改为“woocommerce_before_add_to_cart_form”,但发生了同样的事情。页面上的输出只是带有上下箭头和“添加到购物车”按钮的数量。
    • 抱歉,因为我没有 eventon 插件,所以我无法提供更多帮助。我会联系作者并要求为产品插件添加支持。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-12
    • 1970-01-01
    • 2021-01-21
    • 1970-01-01
    • 1970-01-01
    • 2014-11-21
    相关资源
    最近更新 更多