product

Change markup in WooCommerce shortcode output

痞子三分冷 提交于 2019-12-02 01:16:06
Is it possible to use a WooCommerce shortcode e.g. [product_category category="appliances"] amending the markup to include a <div> tag around some elements? I know I can do this by duplicating what the shortcode does but that seems overkill just to add a wrapping <div> . I could do it with jQuery but don't want any delay in them loading. @Updated Yes this is absolutely possible. You can achieve this with something like that: if( !function_exists('prod_cat') ) { function prod_cat( $atts ) { extract(shortcode_atts(array( 'cat' => '', // category 'class' => '' // Optional adding class to <div>

Automatically assign products to a defined product category in WooCommerce

妖精的绣舞 提交于 2019-12-02 01:15:27
In Woocommerce, I am trying to automatically assign a given product category to products if they have a specific custom field value (Using Advanced custom fields plugin to generate this field). In my functions.php I have : function auto_add_category ($product_id = 0) { if (!$product_id) return; $post_type = get_post_type($post_id); if ( "product" != $post_type ) return; $field = get_field("city"); if($field == "Cassis"){ $terms = get_the_terms( $post->ID, 'product_cat' ); foreach ($terms as $term) { $product_cat_id = $term->term_id; if($product_cat_id != 93){ wp_set_post_terms( $product_id, 93

Disable product data section for specific users only

三世轮回 提交于 2019-12-02 01:14:12
问题 In WooCommerce backend, I know that you can remove the Product tabs globally with some code on functions.php . But I only want to remove for the user back end. I'm using a multivendor plugin. How do I do it? My code: function remove_tab($tabs){ unset($tabs['inventory']); // it is to remove inventory tab //unset($tabs['advanced']); // it is to remove advanced tab //unset($tabs['linked_product']); // it is to remove linked_product tab //unset($tabs['attribute']); // it is to remove attribute

Limit posts on a WP_Query and in WooCommerce product query

…衆ロ難τιáo~ 提交于 2019-12-02 01:08:10
In Woocommerce, I need to limit post with a wp_query . I know how to limit post in wp_query For example if this page id is 20, I am running the query: function wpcodex_filter_main_search_post_limits( $limit, $query ) { if ( get_the_ID()==20 ) { return 'LIMIT 0, 12'; } return $limit; } add_filter( 'post_limits', 'wpcodex_filter_main_search_post_limits', 10, 2 ); But I need to set the limt as 25 to 35. How to do this? Even if I am placing return 'LIMIT 25, 35'; it is still showing first 35 products, not the posts between 25 to 35. That query is like: LIMIT 10 OFFSET 15 Please help me.

Sort a Woocommerce product variations custom output by their price

随声附和 提交于 2019-12-02 00:04:52
Bellow I have a custom shortcode function based on this answer code that displays a block of product data for both Simple products and each variation of a Variable product. The output of the variation blocks seems to be ordered by the ID of the variation itself. For example, this is a screenshot of the frontend output: Which you can see matches the order of the variation IDs (from smallest to largest) screenshot: What I would like is to sort the variations by their prices instead (NOT by their IDs) from lowest to highest. Any help is appreciated. This is the current customized code that I have

Disable product data section for specific users only

[亡魂溺海] 提交于 2019-12-01 21:26:39
In WooCommerce backend, I know that you can remove the Product tabs globally with some code on functions.php . But I only want to remove for the user back end. I'm using a multivendor plugin. How do I do it? My code: function remove_tab($tabs){ unset($tabs['inventory']); // it is to remove inventory tab //unset($tabs['advanced']); // it is to remove advanced tab //unset($tabs['linked_product']); // it is to remove linked_product tab //unset($tabs['attribute']); // it is to remove attribute tab //unset($tabs['variations']); // it is to remove variations tab return($tabs); } add_filter(

Hide variations that don't match Woocommerce

随声附和 提交于 2019-12-01 18:55:01
问题 So I'm currently working on a Woocommerce store that has lots of variations. What I'm basically looking for is for the next variation to refresh based on what was chosen on the variation chosen before that. For example, If you go on http://freelance.tstwebdesign.co.uk/platino/product/plain-platinum-court/ (Apologies for the slow load time) I want to choose a selection from "Width" which should then refresh "Depth" showing only the depths available that match with that width. Is this possible?

Add Woocommerce Temporary product

試著忘記壹切 提交于 2019-12-01 18:15:41
Help Needed: Is it possible to make a user-generated temporary product to be added to cart in WooCommerce? I'm trying to transfer a non-wordpress website to WordPress, but the site already has a sophisticated e-commerce system that the client doesn't want to change. What basically happens is a visitor specifies the measurement of the product that the client is selling, add different variations to it, and then after submitting, the website generates the product's price based on the visitor's input. Adding products will be very tedious because they have too many products with thousands of

Hide variations that don't match Woocommerce

旧巷老猫 提交于 2019-12-01 18:03:52
So I'm currently working on a Woocommerce store that has lots of variations. What I'm basically looking for is for the next variation to refresh based on what was chosen on the variation chosen before that. For example, If you go on http://freelance.tstwebdesign.co.uk/platino/product/plain-platinum-court/ (Apologies for the slow load time) I want to choose a selection from "Width" which should then refresh "Depth" showing only the depths available that match with that width. Is this possible? Thanks! It's default function for not many variations. For many variations you can do it with function

R pairwise product

只谈情不闲聊 提交于 2019-12-01 17:45:22
I'm trying to get the pairwise products of a vector, say a = c(1,2,3,4) What I'm trying to get is 2,3,4,6,8,12 (in that order). I've tried using outer: outer(1:4,2:4) and that gives me a matrix that includes the products I want but I'm not sure how to extract them from the matrix in a way that scales to vectors of higher dimensions. Thanks! combn() is nice for this sort of thing: a <- 1:4 combn(a, m = 2, FUN = prod) # [1] 2 3 4 6 8 12 lower.tri selects them in that order: out <- outer(1:4,1:4) out[lower.tri(out)] # [1] 2 3 4 6 8 12 来源: https://stackoverflow.com/questions/18899332/r-pairwise