product

Get the Product tags for the current product only in WooCommerce

故事扮演 提交于 2020-02-22 07:58:21
问题 How can I display only the product tags for the current single product page and not all the products tags? I've found questions about most popular tags but not for that. 回答1: You can use the function wp_get_post_terms() function for WooCommerce 'product_tag' custom taxonomy and a defined product id this way: $output = array(); // get an array of the WP_Term objects for a defined product ID $terms = wp_get_post_terms( get_the_id(), 'product_tag' ); // Loop through each product tag for the

Get product custom field values as variables in WooCommerce

我只是一个虾纸丫 提交于 2020-02-20 08:57:34
问题 I am using Woocommerce for registration for classes; each class/product has up to 20 custom fields, which I need to return as variables in order to highly customize the checkout and order details pages and customer email template. I don't just want to add all of the custom meta data with hooks, because I need very tight control over the output. For instance, the following answer worked fine for including custom fields in the cart page: Display Custom Field's Value in Woocommerce Cart &

How to hide Woocommerce “out of stock” items price

非 Y 不嫁゛ 提交于 2020-02-15 22:50:30
问题 I'd like to display my out of stock items, but without price in WooCommerce. Is there any easy way to hide price of "out of stock" items? Thanks! 回答1: Adding these to the CSS worked for me. The first one removes the price from the out of stock item's page and the second removes the price from the out of stock item in search results. .outofstock .price{display:none} .outofstock .amount{display:none} 回答2: Create a file price.php in /your-theme/woocommerce/single-product/ folder. Paste the

Add custom content for a specific product on WooCommerce single product pages

孤街醉人 提交于 2020-02-04 03:24:06
问题 In Woocommerce, How can I add a custom content for a specific product on single product pages? Here is an explicit screen shot: 回答1: As your screenshot is not so clear on where you want this custom content you have 2 options: 1) Under the product price With this custom function hooked in woocommerce_before_single_product_summary action hook you can add some custom content to a specific product ID (to be defined in the function) this way: add_action( 'woocommerce_single_product_summary', 'add

Python: shortest way to compute cartesian power of list [duplicate]

时光总嘲笑我的痴心妄想 提交于 2020-02-03 08:50:59
问题 This question already has answers here : Get the cartesian product of a series of lists? (13 answers) Closed 6 years ago . Suppose we have a list L . The cartesian product L x L could be computed like this: product = [(a,b) for a in L for b in L] How can the cartesian power L x L x L x ... x L (n times, for a given n) be computed, in a short and efficient way? 回答1: Using itertools.product(): product = itertools.product(L, repeat=n) where product is now a iterable; call list(product) if you

Update Magento products with multiple images

一笑奈何 提交于 2020-01-30 11:55:26
问题 I'm developing a Magento store and I imported some products, but in these products there were more than just one image and when I imported the products just one came with, now I need to update all the products with the images left, somebody knows how to do it in some quick mode? Thanks! 回答1: Step 1: Export All Products Before you begin, make sure that all changes to the product data have been saved. On the Admin menu, select System > Import/Export > Dataflow - Profiles. In the list of

Update Magento products with multiple images

╄→гoц情女王★ 提交于 2020-01-30 11:55:06
问题 I'm developing a Magento store and I imported some products, but in these products there were more than just one image and when I imported the products just one came with, now I need to update all the products with the images left, somebody knows how to do it in some quick mode? Thanks! 回答1: Step 1: Export All Products Before you begin, make sure that all changes to the product data have been saved. On the Admin menu, select System > Import/Export > Dataflow - Profiles. In the list of

Measurement units conversion based on country in Woocommerce product page

泪湿孤枕 提交于 2020-01-30 07:38:06
问题 I have a woocommerce site set to use Kg and cm as dimension units in the backend settings. The site mainly sells to Europe so no worries. Now I have to sell to US market to and I am being asked to configure the site so that when users in the US-Client group login they see Imperial measurements either as well as or instead of Metric units. Is there a way at least I can display the weight and dimensions in Imperial using some conversion etc and keep primary units as Kg and cm in the database? I

Disable Woocommerce add to cart button if the product is already in cart

假如想象 提交于 2020-01-28 02:30:18
问题 I am trying to set the functionality in Woocommerce on the Add to Cart button to only allow a particular product to be added once to the Cart. Once a particular product has been added to cart the first time, the Add to Cart needs to be hidden. In the cart I can have any number of products - just a max of quantity 1 for each product. I was doing research and saw that I can use woocommerce_add_to_cart_validation hook. But have no idea how to start off. How can I allow a particular product to be

Display custom price based on custom fields for Woocommerce simple product

泪湿孤枕 提交于 2020-01-25 03:05:13
问题 In Woocommerce, I would like update base price depending on 2 selected custom fields. With the help of LoicTheAztec I can update price of 1 custom field, so, how do a update 2 custom fields? PHP code: add_action( 'woocommerce_before_add_to_cart_button', 'custom_product_field' ); function custom_product_field() { global $product; if( $product->is_type('variable') ) return; $options = array( "" => __('Tipos'), "20.00" => "Tipo 1 + 20,00", "25.00" => "Tipo 2 + 25,00", ); woocommerce_form_field(