首页 文章

Woocommerce预订|添加到购物车定制

提问于
浏览
0

我已经使用Woocommerce Plugin安装了Woocommerce Bookings插件 . 我还创建了一个自定义插件,我想在最后添加预订到购物车的默认结帐流程 . 如何才能添加我的可预订产品以添加到购物车,然后使用支付网关结帐?

1 回答

  • 0

    您可以创建具有自己的自定义字段的自定义产品类型 . 将以下代码粘贴到您的functions.php中,尝试创建一个产品,将会有另一种名为Booking Product的产品类型 . 你可能会有所了解 .

    // add a product type
    add_filter( 'product_type_selector', 'wdm_add_custom_product_type' );
    function wdm_add_custom_product_type( $types ){
        $types[ 'booking_product' ] = __( 'Booking Product' );
        return $types;
    }
    add_action( 'plugins_loaded', 'wdm_create_custom_product_type' );
    function wdm_create_custom_product_type(){
         // declare the product class
         class WC_Product_Wdm extends WC_Product{
            public function __construct( $product ) {
               $this->product_type = 'booking_product';
               parent::__construct( $product );
               // add additional functions here
            }
        }
    }
    

相关问题