我想在WooCommerce管理员中添加自定义产品类型。 新产品类型应为简单的产品类型。 查找以下图像以获取更多描述。 https://docs.google.com/file/d/

问题描述 投票:0回答:1

https://docs.google.com/file/d/0b6n5mn7suesdoef0ukhymjfysda/edit

thanks和ward chirag

您可以在几秒钟内通过使用此wooCommerce(附加组件,数据,选项,预订和约会)轻松地做到这一点。 或使用此代码:

// #1 Add New Product Type to Select Dropdown add_filter( 'product_type_selector', 'wpsaad_add_custom_product_type' ); function wpsaad_add_custom_product_type( $types ){ $types[ 'custom' ] = 'Custom product'; return $types; } // -------------------------- // #2 Add New Product Type Class add_action( 'init', 'wpsaad_create_custom_product_type' ); function wpsaad_create_custom_product_type(){ class WC_Product_Custom extends WC_Product { public function get_type() { return 'custom'; } } } // -------------------------- // #3 Load New Product Type Class add_filter( 'woocommerce_product_class', 'wpsaad_woocommerce_product_class', 10, 2 ); function wpsaad_woocommerce_product_class( $classname, $product_type ) { if ( $product_type == 'custom' ) { $classname = 'WC_Product_Custom'; } return $classname; }
wordpress woocommerce
1个回答
0
投票
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.