i have variable products in woocommerce store , instead of displaying range of prices, i'd display default price shows below when first visits product page.
for attached image, default price $395. changes based on choices person makes after they've loaded product page. $395 number stay @ top of page "starting @ $395" or "baseline price" or that.
but getting $395 number out of woocommerce has been challenging me i'm reaching out.
this answered here: woocommerce variation product price show default
but it's woocommerce 2.0 store , i'm using latest version 2.5.5 , persons code gives me minimum fee instead of default fee , don't know change based on updated woocommerce code.
any suggestions?
i have tried many versions of code include them here confusing probably. if don't hear anyone, i'll include some.
i cant find answer question anywhere (how display price default product variation instead of price range?) created code:
add_filter('woocommerce_variable_price_html', 'custom_variation_price', 10, 2); function custom_variation_price( $price, $product ) { foreach($product->get_available_variations() $pav){ $def=true; foreach($product->get_variation_default_attributes() $defkey=>$defval){ if($pav['attributes']['attribute_'.$defkey]!=$defval){ $def=false; } } if($def){ $price = $pav['display_price']; } } return woocommerce_price($price); }
this plugin show price default variation, of course if set default values before. tested on woocommerce version 2.6.2.
Comments
Post a Comment