product

Woocommerce - Check if product was created less than 60 days ago

陌路散爱 提交于 2021-02-20 04:08:16
问题 I want to check if a Woocommerce product was created less than 60 days ago. - If true, do something. I am obtaining the date the product was created in backend/admin using the official Woocmmerce function $product->get_date_created . My code partially works, but it seems to be checking if $product->get_date_created literally contains the value 60 instead of perfoming the calculation and minusing 60 days from the current DateTime . I have come to this conclusion because my IF statement runs

Woocommerce - Check if product was created less than 60 days ago

守給你的承諾、 提交于 2021-02-20 04:08:10
问题 I want to check if a Woocommerce product was created less than 60 days ago. - If true, do something. I am obtaining the date the product was created in backend/admin using the official Woocmmerce function $product->get_date_created . My code partially works, but it seems to be checking if $product->get_date_created literally contains the value 60 instead of perfoming the calculation and minusing 60 days from the current DateTime . I have come to this conclusion because my IF statement runs

Woocommerce - Check if product was created less than 60 days ago

强颜欢笑 提交于 2021-02-20 04:06:36
问题 I want to check if a Woocommerce product was created less than 60 days ago. - If true, do something. I am obtaining the date the product was created in backend/admin using the official Woocmmerce function $product->get_date_created . My code partially works, but it seems to be checking if $product->get_date_created literally contains the value 60 instead of perfoming the calculation and minusing 60 days from the current DateTime . I have come to this conclusion because my IF statement runs

Add a purchase condition to WooCommerce products

◇◆丶佛笑我妖孽 提交于 2021-02-19 09:13:29
问题 I ma trying to add a purchase condition to my WooCommerce products with the following: {$current_user = wp_get_current_user(); if ( current_user_can('administrator') || wc_customer_bought_product($current_user->email, $current_user->ID, // return true return true;} But I don't know if this code is correct and an advise will be helpful. 回答1: The product Id argument is missing from wc_customer_bought_product() function, and you can get more easily the WP_User object. Here is a usage example:

Display description before the title in WooCommerce product category archives

你离开我真会死。 提交于 2021-02-19 08:50:53
问题 In WooCommerce, I am trying to display the description before the title in Product category archive pages. But I fail trying to find out what hooks could I use to do it. The idea was to have a "Flavour Menu" be displayed first, and then the title afterwards, like in this screenshot: Any track is appreciated. 回答1: You will need to override the template templates/archive-product.php located in the Woocommerce plugin, copying it to your active theme folder to a woocommerce subfolder (but not in

Hiding products without thumbnail in WooCommerce shop page

不问归期 提交于 2021-02-19 08:13:07
问题 I use importer which imports thousands of products to the shop. Although I must insert picture and description for the product before I want to sell the item. I would like to hide product from the store at all IF there is no thumbnail image assigned. This way new products appear to the shop only after I have set the thumbnail image. I tried this in header.php, but did not work: <?php if($_product->getImage() && $_product->getImage() != 'no_selection'){ ?> <style> /* Css to hide Featured image

Change Related Products Heading adding the product name in WooCommerce

自闭症网瘾萝莉.ら 提交于 2021-02-19 06:48:04
问题 I have this code which is an attempt in translating "Related products" into "These will go well with PRODUCT NAME". Here's my code: add_filter( 'gettext', 'change_related_products_title', 10, 3 ); function change_related_products_title( $translated, $text, $domain ) { $ptitle = get_page_by_title( 'Product Title', OBJECT, 'product' ); if( $text === 'Related products' && $domain === 'woocommerce' ){ $translated = esc_html__( 'These go well with '.$ptitle.' ', $domain); } return $translated; }

Product regular price calculation based on 2 custom fields in Woocommerce 3

白昼怎懂夜的黑 提交于 2021-02-19 03:08:32
问题 In Woocommerce I have set 2 custom fields in the admin in the pricing section under Woocommerce default prices fields: Margin rate and Purchase price. I am trying to figure out how can I auto update the product price (regular price field) based on the calculation below: $product_price = $rate_margin * $purchase_price; Any help is appreciated. 回答1: You should add alway add the code that is used for your additional pricing fields in your question. The code below is: displaying and saving 2

Product regular price calculation based on 2 custom fields in Woocommerce 3

本小妞迷上赌 提交于 2021-02-19 03:06:34
问题 In Woocommerce I have set 2 custom fields in the admin in the pricing section under Woocommerce default prices fields: Margin rate and Purchase price. I am trying to figure out how can I auto update the product price (regular price field) based on the calculation below: $product_price = $rate_margin * $purchase_price; Any help is appreciated. 回答1: You should add alway add the code that is used for your additional pricing fields in your question. The code below is: displaying and saving 2

Product regular price calculation based on 2 custom fields in Woocommerce 3

穿精又带淫゛_ 提交于 2021-02-19 03:05:42
问题 In Woocommerce I have set 2 custom fields in the admin in the pricing section under Woocommerce default prices fields: Margin rate and Purchase price. I am trying to figure out how can I auto update the product price (regular price field) based on the calculation below: $product_price = $rate_margin * $purchase_price; Any help is appreciated. 回答1: You should add alway add the code that is used for your additional pricing fields in your question. The code below is: displaying and saving 2