Dynamic Product Variation in WooCommerce
-
I installed WooCommerce and have 3 variable products, however I’d like to add the variation “language”. I don’t want to add as meta information for the products (in the gui), but I would like to use a hook, so I can say that every variable product has a language variation – english and german. I tried using the filter
woocommerce_display_product_attributes
:add_filter('woocommerce_display_product_attributes', function($atts, $product) { $product_attributes = $product->get_attributes(); $languages = new WC_Product_Attribute(); $languages->set_id(0); $languages->set_name('language'); $languages->set_options(['english','german']); $languages->set_position(0); $languages->set_visible(1); $languages->set_variation(1); return [ $product_attributes, $languages ]; }, 10, 2);
Can someone help me out with this? I would be really grateful!
- The topic ‘Dynamic Product Variation in WooCommerce’ is closed to new replies.