Questions tagged [product-variations]

106 questions
18
votes
8 answers

Create programmatically a WooCommerce product variation with new attribute values

I have created a variable product ("parent" product) in WooCommerce version 3+. From a WordPress plugin, I would like to programmatically create the product variations ("children" product) with new attribute values. The variation attributes are…
Cedric
  • 4,361
  • 10
  • 37
  • 55
8
votes
3 answers

WooCommerce: Display also product variation description on cart items

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…
simplycity
  • 83
  • 1
  • 1
  • 5
7
votes
2 answers

WooCommerce - Ignore unselected variations when adding to cart

Objective: add product to cart despite unselected variations, i.e. remove/disable the mandatory nature of variation fields. Issue: WooCommerce's absolute requirement for all variations to be selected before adding to cart. Tried: filtering…
UncaughtTypeError
  • 6,718
  • 2
  • 17
  • 35
5
votes
1 answer

Add some attribute values to WooCommerce variable product title from chosen variation

I'm 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…
Jens
  • 135
  • 1
  • 3
  • 9
5
votes
1 answer

Variable product attribute: Customizing each displayed radio buttons text value

In WooCommerce I am using WC Variations Radio Buttons plugin (by 8manos) to replace the typical dropdown selectors with Radio Buttons. I've added the below code to my child themes function.php: // Display the product variation price inside the…
4
votes
1 answer

Woocommerce how to ajaxify add to cart button for variable products using custom html radio buttons instead of dropdown menu - no plugin

I'm trying to put all of the pieces of this puzzle together. I've been reading all of the questions and answers on this subject for the past 3 days. So the general blueprint that i'm following is as follows: On single product page, first checking…
3
votes
2 answers

WooCommerce products: Allow backorders only for specific user roles

I want to allow backorders for specific customer roles. Code i writed is: // BackOrder Allow Part #1 add_filter( 'woocommerce_product_backorders_allowed', 'woocommerce_product_backorders_allowed', 10, 3 ); function…
3
votes
1 answer

Display a selected variation custom field in WooCommerce as a pdf linked file

I want to be able to add external links with documentation for my products. With this code I added for simple products and it works as I wish: // This function gets the value for the the custom fields from the database and adds it to the frontend…
3
votes
1 answer

Display selected variation custom fields value in WooCommerce product additional information tab

I have been able to add a custom text input field to the variations of my variable products using the following code: // Add custom text input field to admin Product Data > Variations add_action( 'woocommerce_variation_options_pricing',…
3
votes
1 answer

Set and display a custom product variation value dynamically on WooCommerce single products

I have a WooCommerce jewelry site. On single variable product page I have variations and I added a text box (text box is for the customer to write something that will be printed on the jewelry). So I expect the page to work as follows: If the…
flicko
  • 33
  • 4
3
votes
3 answers

How to re save all variations of a variable product when a WooCommerce order is paid?

I use following code to re save the product variations, when there is a paid order on it, but nothing happen add_action('woocommerce_payment_complete', 'refresh_zero_stock'); function refresh_zero_stock($order_id){ $order = new WC_Order(…
Web Design
  • 129
  • 15
3
votes
1 answer

Issue when trying get the product variation object from order items

on WooCommerce, I'm trying to get the variation name of a product. But I'm getting the message error : Call to undefined function wc_get_product(). Here is the code: (the file where this code is, is from a application that make some request to the…
3
votes
1 answer

How to update each product variation of a variable product in WooCommerce

I have a product with a list of variations, as an example one of the variations is "36" (ID: 17393). I want to set a new price and a new quantity of this variation of the product (with external information). For now, I have this code, but I have…
mikesneider
  • 599
  • 5
  • 22
3
votes
1 answer

List product variations using wc_dropdown_variation_attribute_options in Woocommerce

I am new to woocommerce and i am trying to display the product variations as a drop-down list in shop page. But the variations are not getting populated in the select option list. below is my code snippet. get_attributes()…
Nevin Thomas
  • 738
  • 3
  • 9
  • 23
3
votes
1 answer

Woocommerce Deleted Products Variations Remain

I have recently added the WP All Exports Plugin to my Wordpress site and exported a list of all the products from my woocommerce store. I have noticed that I have in excess of 100 Variants on the CSV file shown which the Parent Product has been…
PaulMcF87
  • 347
  • 3
  • 15
1
2 3 4 5 6 7