Closed. This question is off-topic. It is not currently accepting answers.admin管理员组文章数量:1124161
Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 10 months ago.
Improve this questionI've got a Wordpress/Woocommerce installation.
On the category page, products either have an 'Add to Cart' button or 'Read more' button depending on whether each is purchasable.
When I look at the is_purchasable() function in Woocommerce, this is the function call that makes the determination:
plugins/woocommerce/includes/class-wc-product-simple.php
public function add_to_cart_text() { $text = $this->is_purchasable() && $this->is_in_stock() ? __( 'Add to cart', 'woocommerce' ) : __( 'Read more', 'woocommerce' ); return apply_filters( 'woocommerce_product_add_to_cart_text', $text, $this ); }
This is working as the products all have the correct buttons. Now, I'm trying to figure out the inner workings of is_purchasable. I've scoured through the code in the plugins and themes directories to find instances of is_purchasable being declared somewhere and all I've found are these declarations:
woocommerce/includes/class-wc-product-external.php:
public function is_purchasable() { return apply_filters( 'woocommerce_is_purchasable', false, $this ); }
woocommerce/includes/class-wc-product-grouped.php
public function is_purchasable() { return apply_filters( 'woocommerce_is_purchasable', false, $this ); }
woocommerce/includes/class-wc-product-variation.php
public function is_purchasable() { return apply_filters( 'woocommerce_variation_is_purchasable', $this->variation_is_visible() && parent::is_purchasable() && ( 'publish' === $this->parent_data['status'] || current_user_can( 'edit_post', $this->get_parent_id() ) ), $this ); }
woocommerce/includes/abstracts/abstract-wc-product.php
public function is_purchasable() { return apply_filters( 'woocommerce_is_purchasable', $this->exists() && ( 'publish' === $this->get_status() || current_user_can( 'edit_post', $this->get_id() ) ) && '' !== $this->get_price(), $this ); }
There is obviously logic somewhere that is determining a product is not purchasable if it's price is not defined or is 0.
Can anyone offer some ideas as to where this logic is hidden?
本文标签: pluginsWhere is code for ispurchasable defined in Woocommerce
版权声明:本文标题:plugins - Where is code for is_purchasable defined in Woocommerce 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736619778a1945547.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论