variations

Get the product variations attributes values term ID and name

北城余情 提交于 2019-12-07 02:39:58
问题 In WooCommerce, I'm using $product->get_variation_attributes() to get the variations attributes for a product. This function returns an array with the names without the ID's. Like this: [pa_color-shirt] => Array ( [0] => red [7] => grey [14] => yellow ) [pa_color-sweater] => Array ( [0] => red [1] => green [2] => blue [3] => grey [4] => yellow [5] => pink [6] => dark-blue ) For the AJAX shop I'm creating I also need the ID's from the variations. So I can append the Id's and the names to the

Woocommerce: Display Product Variation Description on order page

痞子三分冷 提交于 2019-12-06 23:42:34
I am trying to display the product variation description in the order detail page and in the order email. Following this example Woocommerce: Display Product Variation Description on Cart page it worked perfectly for the cart and also for the checkout. But it seems i can't find the right way of calling it for the order page. This $item = $cart_item['data']; if(!empty($item) && $item->is_type( 'variation' ) ){ echo '<dl><dd>' . $item->get_variation_description() } is not working, as it calls for the cart item data .. And the get_post_meta as suggested here WooCommerce displaying variable

Display the default variation price and savings amount on Woocommerce 3

两盒软妹~` 提交于 2019-12-06 11:54:13
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('variable') ? $product->get_variation_regular_price( 'min', true ) : $product->get_regular_price(); $sale

Replace the Variable Price range by the chosen variation price in WooCommerce 3

不羁的心 提交于 2019-12-06 11:22:23
On WooCommerce I would like to change the Variable single product page layout. Because, when you have an variable product you get this wired price rage ( below product title ) in the Variable Product page and it shows in the shop page as well. For me the standard way is to show the lowest price of the product in the shop as well as product page and change that price according to user selection of variables. I can't believe why. I can remove the price range and show the lowest price using this code snippet. https://businessbloomer.com/disable-variable-product-price-range-woocommerce/ But then

WooCommerce: Get Product Variation ID from Matching Attributes

我们两清 提交于 2019-12-06 10:02:42
How I get product variation id from custom product loop. I have variation attribute like, { 'pa_color'=>'red','pa_size'=>'large'} 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_Store_CPT())->find_matching_product_variation( new \WC_Product($product_id), $attributes ); } Don't have enough

Enable sale price for logged users and regular price for unlogged users in Woocommerce

放肆的年华 提交于 2019-12-06 08:20:43
In Woocommerce I have a variable products with many variations and every variation has its own REGULAR price and SALE price. I would like when user: is logged in, the sale price will be the active price is not logged in, the regular price will be the active price. I have added this hooked function in my child theme function.php file: add_filter( 'woocommerce_available_variation', 'my_variation', 10, 3); function my_variation( $data, $product, $variation ) { wc_delete_product_transients($variation->get_id()); $variation_id = $variation->get_id(); $variable_product1= new WC_Product_Variation(

Change WooCommerce variable product title based on variation

大兔子大兔子 提交于 2019-12-06 03:42:40
问题 Im looking for some help getting the WooCommerce variable product title to change based on variations. In this specific case i would like the title to change when a color is selected, like "Productname Black". Is there any easy snippet to get this to work? Thankfull for all the help i can get. 回答1: UPDATE FEB 2018 The following code, will add to title the color attribute vakue of the chosen variation, meaning that if there is many select fields (many attributes), the color text value will be

Add custom dimension fields to each variation settings for variable products

主宰稳场 提交于 2019-12-06 02:57:54
问题 I'm trying to add a "Built Dimensions" fields to each product variation settings. Here's a mock of what I'm trying to accomplish: I've followed these following tips but they aren't doing quite what I want: http://www.remicorson.com/mastering-woocommerce-products-custom-fields/ Add Advanced Custom Fields to WooCommerce Product Variation Those are adding it to one of the other data tabs. I need it per variation. Each variation has a built dimension and a shipping dimension. 回答1: With the 2

Woocommerce: Display Product Variation Description on Cart page

二次信任 提交于 2019-12-06 01:29:48
问题 I'm trying to display my product variation description in my Cart. I have tried inserting this code in the cart.php template: if ( $_product->is_type( 'variation' ) ) {echo $_product->get_variation_description();} By following this documentation https://docs.woocommerce.com/document/template-structure/ But it's still not showing up. Not sure what I'm doing wrong here. Can anyone help on this? Thanks 回答1: UPDATE COMPATIBILITY for WooCommerce version 3+ Since WooCommerce 3, get_variation

Display all products and variations on the shop page, while maintaining pagination

喜夏-厌秋 提交于 2019-12-05 22:35:17
I need to display every product, and in case it's a variable product (e.g. multiple colors), each variation on the shop page. At first, I've wrote my own query to retrieve all variations if the product had them: $product = get_product(); global $variable_id; global $color; if ($product->product_type == "variable") { $variations = $product->get_available_variations(); foreach ($variations as $variation) { $color = $variation["attributes"]["attribute_pa_colour"]; $variable_id = $variation['variation_id']; wc_get_template_part('content', 'product'); } } else { $variable_id = null; $color = null;