product

WooCommerce shows the placeholder image when using get_image()

不想你离开。 提交于 2020-01-17 06:17:39
问题 I am developing a custom WooCommerce theme and every time I try to retrieve a product's image, all I get is the placeholder image. I've already set the image in the back-end so it should work properly, but it doesn't. Here is my code: $args = array( 'post_type' => 'product', 'posts_per_page' => 2 ); $products = get_posts($args); foreach($products as $the_product) { $wc_product = new WC_Product($the_product->id); echo $wc_product->get_image('shop_thumbnail'); } This is the result: Could you

SQL query to change backorder status of all products in WooCommerce

左心房为你撑大大i 提交于 2020-01-16 18:11:31
问题 In WooCommerce you can change the status of a product to allow backorders, the default setting is 'not allowed'. I have thousands of products on my shop and I rather not change it manually for all of them. Is there an SQL query that could do this for me directly in the database? 回答1: Try running this query in mySql UPDATE wp_postmeta SET meta_value = 'yes' WHERE meta_key = '_backorders'; This is not enough to achieve your purpose. Need to enable Manage stock as well. Try running this query

SQL query to change backorder status of all products in WooCommerce

烂漫一生 提交于 2020-01-16 18:10:36
问题 In WooCommerce you can change the status of a product to allow backorders, the default setting is 'not allowed'. I have thousands of products on my shop and I rather not change it manually for all of them. Is there an SQL query that could do this for me directly in the database? 回答1: Try running this query in mySql UPDATE wp_postmeta SET meta_value = 'yes' WHERE meta_key = '_backorders'; This is not enough to achieve your purpose. Need to enable Manage stock as well. Try running this query

SQL query to change backorder status of all products in WooCommerce

若如初见. 提交于 2020-01-16 18:09:55
问题 In WooCommerce you can change the status of a product to allow backorders, the default setting is 'not allowed'. I have thousands of products on my shop and I rather not change it manually for all of them. Is there an SQL query that could do this for me directly in the database? 回答1: Try running this query in mySql UPDATE wp_postmeta SET meta_value = 'yes' WHERE meta_key = '_backorders'; This is not enough to achieve your purpose. Need to enable Manage stock as well. Try running this query

Display a random product thumbnail for a product category in WooCommerce

风流意气都作罢 提交于 2020-01-15 10:40:09
问题 I am trying to pull a random product thumbnail to display as an image on one of my pages. I can't seem to find a way that works, and have tried the solutions from this and this post. It would be beneficial to echo it out in a div as well. Here is what I am currently trying but I'm still unsure how to do this. functions.php: function get_random_thumbnails_for_reg(){ if(is_page(381)){ $args = array( 'tax_query' => array( array( 'taxonomy' => 'product_cat', 'field' => 'slug', 'terms' => 'allison

Get the grouped product link from one of it's childs in woocommerce 3

核能气质少年 提交于 2020-01-13 07:09:48
问题 With woocommerce 2.3 there was post_parent for single products what was the part of grouped product. So it was possible to link them by: function parent_permalink_button() { global $post; if( $post->post_parent != 0 ){ $permalink = get_permalink($post->post_parent); echo '<a class="button" href="'.$permalink.'">Link to Parent</a>'; } } with woocommerce 3.0.0 update situation changed. Actually it is opposite now. Grouped product has its _children. How can I create the link from single product

Magento: template based on attribute set

夙愿已清 提交于 2020-01-13 04:31:06
问题 I want to create different product views based on the attribute set the product belongs to: does Magento provide a way to do this? - UPDATE - Following dan.codes suggestion I've added $update->addHandle('PRODUCT_ATTRIBUTE_SET_ID_'.$product->getAttributeSetId()); to Mage_Catalog_ProductController (I duplicated ProductController.php and put it in local/Mage/Catalog/controllers/). Then I added this to catalog.xml <PRODUCT_ATTRIBUTE_SET_ID_9> // PRODUCT ID of Book Attribute Set <label>Catalog

Display discount percentage after the selected variation sale price in WooCommerce

余生长醉 提交于 2020-01-11 07:24:09
问题 I've this code below that shows the variation selected price after the user have selected the variation add_filter( 'woocommerce_show_variation_price', 'filter_show_variation_price', 10, 3 ); function filter_show_variation_price( $condition, $product, $variation ){ if( $variation->get_price() === "" ) return false; else return true; } I need to calculate the discount percentage between the promotional price that will show and the regular price. BUT ONLY after the variation is selected, not

Remove a specific cart item when adding to cart a specific product in Woocommerce

北战南征 提交于 2020-01-11 07:01:05
问题 With WooCommerce, I am looking to see if it's possible to remove a specific item (from cart), if another specific item is in the cart. My web shop has a free version of a product which gives to customer a basic access to site content. The paid version will open up more access to content. This way if the free version is already in the cart, and the paid version gets added to cart, then the free version will be removed from cart. I tried looking at possible options and plugins but most of them

Is there an API for the Amazon Vendor Central? [closed]

牧云@^-^@ 提交于 2020-01-11 05:05:08
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . In order to manage our products easier I would like to use an API if there is any. Is there any way to manage the products programmatically? Currently, my impression is that there is only the web access, which is quite cumbersome to use if there are hundreds of products. Our data comes from another system which