product

How can I set tab (only) if the product is in a certain category WooCommerce

爷,独闯天下 提交于 2019-12-10 15:55:37
问题 I have a tab set to add a tab which contains specifications in WooCommerce. I'd like to wrap it into an if statement to only set the tab if the product is part of a certain category. add_filter( 'woocommerce_product_tabs', 'woo_custom_product_tabs' ); function woo_custom_product_tabs( $tabs ) { global $post; if ($product->is_category("Mobile Phones")) { $tabs['custom_specification'] = array( 'title' => __( 'Specification', 'woocommerce' ), 'priority' => 50, 'callback' => 'woo_custom

Variable product attribute: Customizing each displayed radio buttons text value

℡╲_俬逩灬. 提交于 2019-12-10 14:23:21
问题 In WooCommerce I am using WC Variations Radio Buttons plugin (by 8manos) to replace the typical dropdown selectors with Radio Buttons . I've added the below code to my child themes function.php : // Display the product variation price inside the variations dropdown. add_filter( 'woocommerce_variation_option_name', 'display_price_in_variation_option_name' ); function display_price_in_variation_option_name( $term ) { global $wpdb, $product; if ( empty( $term ) ) return $term; if ( empty(

WooCommerce Subscriptions - Check if product already has an active subscriber

谁说胖子不能爱 提交于 2019-12-10 14:12:32
问题 I am using a plugin "WooCommerce Subscriptions" and I want to check if the product already has the active subscriber in the system I only want 1 subscriber per product. There is a filter available to check it but I don't know how to use it: https://docs.woocommerce.com/document/subscriptions/develop/filter-reference/ How can I use that functions or hooks, to achieve this? Thanks 回答1: This custom made conditional function will return true if a subscription product is already actively used by a

WooCommerce - Get custom product attribute

倾然丶 夕夏残阳落幕 提交于 2019-12-10 13:58:43
问题 I am trying to get a specific custom attribute in woocommerce. I've read tons of threads on this site which offer about 3-5 methods how to do it. After trying all, the only method that worked for me is to loop through all attributes - all others did not work. I have a custom attribute named 'pdfs' The following tries did not work: (link) $global product; $myPdf = array_shift( wc_get_product_terms( $product->id, 'pdfs', array( 'fields' => 'names' ) ) ); $myPdf = $product->get_attribute( 'pdfs'

Exclude product from all coupons in WooCommerce

懵懂的女人 提交于 2019-12-10 12:31:46
问题 I have searched all over the internet, but it doesn't seem to be any answer anywhere in spite of countless people asking the question. Is there any way to exclude a specific product from ALL coupons? I understand that you can do it on coupon level, but this is rather messy especially as a lot of people have automatic coupons, several people creating coupons etc… TLDR: Any way to make a product excluded from all coupons at Product level . 回答1: Here is a nice way to automate this process. 1) We

Why does my JavaScript function accept three arrays, but not an array containing three arrays?

拈花ヽ惹草 提交于 2019-12-10 12:16:49
问题 function product() { return Array.prototype.reduce.call(arguments, function(as, bs) { return [a.concat(b) for each (a in as) for each (b in bs)] }, [[]]); } arr4=[['4','4A','4B'],['16D','15D'],['5d','5e']]; alert(product(['4','4A','4B'],['16D','15D'],['5d','5e']); The above works but the following don't work: arr4=[['4','4A','4B'],['16D','15D'],['5d','5e']]; alert(product(arr4); Thanks for suggestions 回答1: You can have either one or the other; otherwise it's poorly defined. (Unless you want

Restrict woocommerce product to certain customer to buy

谁说我不能喝 提交于 2019-12-10 11:59:06
问题 I am setting up an eCommerce website selling household's stuff. I'd like some products to be purchased by regular visitors but some products (with lots of discounts) are retricted to certain Memberships only (namely wholesalers) and these products shows to every visitors but when a regular visitor clicks on "add to cart", it will re-direct to a membership registeration form with a note: Only wholesale member are allowed to purchase this item. I am building a woocomerce multilingual website

Display the default variation price and savings amount on Woocommerce 3

五迷三道 提交于 2019-12-10 11:25:12
问题 I need to display default variation price & with regular price & savings amount on my Woocommerce Homepage & Category Page I found following code on this links answer Display lowest variation price and discounted percentage in WooCommerce add_filter( 'woocommerce_get_price_html', 'custom_price_format', 10, 2 ); add_filter( 'woocommerce_variable_price_html', 'custom_price_format', 10, 2 ); function custom_price_format( $price, $product ) { // Main Price $regular_price = $product->is_type(

Stop the redirection after WooCommerce add to cart

喜夏-厌秋 提交于 2019-12-10 11:06:31
问题 I wish to completely remove any redirection after a user click on the ADD TO CART button. Actually I am not using the products page. I am using a simple button with the link to the product, like this: ?add-to-cart=492 . My user will click on several "add to cart" buttons on my page, so he cant be redirected to any page after clicking in the first button. At the end of the page he will find a CHECKOUT button to pay and that is it. Any ideas how to achieve this? Thanks 回答1: Update: Your simple

WooCommerce: Get Product Variation ID from Matching Attributes

会有一股神秘感。 提交于 2019-12-10 11:06:09
问题 How I get product variation id from custom product loop. I have variation attribute like, { 'pa_color'=>'red','pa_size'=>'large'} 回答1: Set of attributes to match are [ 'attribute_pa_color' => 'blue', 'attribute_pa_size' => 'small', ]; Below is the function I ended up creating to achieve this: /** * Find matching product variation * * @param $product_id * @param $attributes * @return int */ function find_matching_product_variation_id($product_id, $attributes) { return (new \WC_Product_Data