Closed. This question is off-topic. It is not currently accepting answers.admin管理员组文章数量:1406926
Your question should be specific to WordPress. Generic PHP/JS/HTML/CSS questions might be better asked at Stack Overflow or another appropriate site of the Stack Exchange network. Third party plugins and themes are off topic.
Closed 11 years ago.
Improve this questionI want to add a new custom "product type" to woocommerce plugin:
Tried to duplicate one of currently exist product type files (woocommerce template structure) as a new file (file name and inside commented name) but not worked!
Closed. This question is off-topic. It is not currently accepting answers.Your question should be specific to WordPress. Generic PHP/JS/HTML/CSS questions might be better asked at Stack Overflow or another appropriate site of the Stack Exchange network. Third party plugins and themes are off topic.
Closed 11 years ago.
Improve this questionI want to add a new custom "product type" to woocommerce plugin:
Tried to duplicate one of currently exist product type files (woocommerce template structure) as a new file (file name and inside commented name) but not worked!
Share Improve this question asked Oct 26, 2013 at 22:19 AminoAmino 3232 gold badges5 silver badges17 bronze badges1 Answer
Reset to default 20The add to cart template is only 1 of the many things you'll need to do. Each product type has it's own class in the /includes/
folder. Each one extends the WC_Product
class.
To add items to the list you've screencapped (which is on the admin side and not the front-end, unlike the add-to-cart.php
template, you will need to filter product_type_selector
.
add_filter( 'product_type_selector', 'wpa_120215_add_product_type' );
function wpa_120215_add_product_type( $types ){
$types[ 'your_type' ] = __( 'Your Product Type' );
return $types;
}
then you'll need to declare your product class. The standard naming system is WC_Product_Type_Class
so in this example it would be:
class WC_Product_Your_Type extends WC_Product{
/**
* __construct function.
*
* @access public
* @param mixed $product
*/
public function __construct( $product ) {
$this->product_type = 'your_type'; // Deprecated as of WC3.0 see get_type() method
parent::__construct( $product );
}
/**
* Get internal type.
* Needed for WooCommerce 3.0 Compatibility
* @return string
*/
public function get_type() {
return 'your_type';
}
}
You are asking a very complicated question and I can't provide a more complete answer. Hopefully this sets you on the right path. I highly encourage you to read the code in WooCommerce. It is very well commented and you can see how they are handling the different product types.
Edit Added WC3.0 compatibility to product type class.
本文标签: customizationHow to add a new product type on woocommerce product types
版权声明:本文标题:customization - How to add a new product type on woocommerce product types? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745040290a2639037.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论