Add description below price

Home Forums Legacy Support Support queries How-to & Troubleshooting Add description below price

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #201722
    erickpaulino
    Spectator
    Hello guys, I am using the feature of assigning multiple products to one course. That creates a dropdown on the price, so that the user can choose the associated product. But that may be confusing for some (specially in my case because I want to offer a simple product option and a subscription option with very different prices). Could you help me add a description below each price on the drop down just like the image below? (check the description in yellow below the price) http://docelimao.com.br/price_description.JPG Thank you! Erick
    #201723
    erickpaulino
    Spectator
    Hi there, I have partially achieved what I want. I added a custom attribute to the product (descricao_preco) and called it on the PHP code for multiple course products in functions.php just like below:
    $price_html = str_replace('class="amount"','class="amount" itemprop="price"',$product->get_price_html()).''.$product->get_attribute('descricao_preco').'';
    That displays the option but only for the additional products, not the first (main) one. Could you help me add that to the first product displayed in the drop down as well? Thank you, Erick
    #201727
    erickpaulino
    Spectator
    Hey guys, I did it! Here is the code if anyone needs it: /* ADDS PRODUCT CUSTOM ATTRIBUTE BELOW PRICE */ // simple product function adiciona_atributo_preco( $price_html, $product ) { if( $product->is_type( 'simple' ) ) { $price_html = $price_html.''.$product->get_attribute('descricao_preco').''; return $price_html; } else { return $price_html; } } add_filter( 'woocommerce_get_price_html', 'adiciona_atributo_preco', 10, 2 ); // subscription product function adiciona_atributo_periodo($subscription_string, $product ) { if( $product->is_type( 'subscription' ) ) { $subscription_string = $subscription_string.''.$product->get_attribute('descricao_preco').''; return $subscription_string; } } add_filter( 'woocommerce_subscriptions_product_price_string', 'adiciona_atributo_periodo', 10, 2 );
    #201862
    Anshuman Sahu
    Keymaster
    Wow that is cool .thanks for sharing the snippet here . Hope it helps others .
Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Add description below price’ is closed to new replies.