Issue with product dropdown with price
-
I made a cool dropdown with prices in my shop with this code from Branahr. Thanks for that.
Now i have an issue, because i started to have stock quantities for each product. And the dropdown displays the stock amount, which is confusing to the customer. Does anybody know how i can have this dropdown, but without it showing the amount in stock?
Thanks in advance ??
function display_price_in_variation_option_name( $term ) { $product = wc_get_product(); $id = $product->get_id(); if ( empty( $term ) || empty( $id ) ) { return $term; } if ( $product->is_type( 'variable' ) ) { $product_variations = $product->get_available_variations(); } else { return $term; } foreach($product_variations as $variation){ if(count($variation['attributes']) > 1){ return $term; } foreach($variation['attributes'] as $key => $slug){ if("attribute_" == mb_substr( $key, 0, 10 )){ $taxonomy = mb_substr( $key, 10 ) ; $attribute = get_term_by('slug', $slug, $taxonomy); if($attribute->name == $term){ $term .= " (" . wp_kses( wc_price($variation['display_price']), array()) . ")"; } } } } return $term; } add_filter( 'woocommerce_variation_option_name', 'display_price_in_variation_option_name' );
The page I need help with: [log in to see the link]
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Issue with product dropdown with price’ is closed to new replies.