Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am kind of new to woocommerce but finding this plugin amazing so far.. I am trying to figure out how to add a variable right after the price which will give the buyer additional information about how many credits he purchased (using stars)

There is an option of adding attributes and showing them as variables but it all shows underneath in the "Additional information" tab and I want that to appear right after the price

the following screenshot better describe what I am looking for: enter image description here

*This "stars" additional information must be added to the checkout page as well as sent to the customer as additional important information

Thanks in advance
Gil

share|improve this question

1 Answer 1

use woocommerce_single_product_summary action hook with priority 15

//test
add_action('woocommerce_single_product_summary','ravs_credits',15);
function ravs_credits(){
    echo'testing';
}

above code print testing below price on product page.

Important Link:

woocommerce_single_product_summary hook

WordPress hooks introduction


Updated:

I am assuming that your credit range form 1 to 100 and you specify them.now

  1. create custom meta box in product post type.read How To Create Custom Post Meta Boxes
  2. read this technique to create product rating in css

now you get meta box in each product,give it a value between 1 to 100 now code look like

//credits with rating
    add_action('woocommerce_single_product_summary','ravs_credits',15);
    function ravs_credits(){
     global $post;
     ?>
     <div class="ravs-credits">
       <p>This package will grant you <?php echo get_post_meta($post->ID, $key, $single); ?> Stars</p>
       <span style="width:<?php echo get_post_meta($post->ID, $key, $single); ?>%" class="rating"></span>
     </div>
     <?php
    }

Important Link:

  1. get_post_meta()
share|improve this answer
    
Basically it works pretty well thanks. How do I display the attribute instead of echoing a simple text? (testing) –  gil hamer Jun 5 '13 at 14:59
    
for that you have to dig in that plugin code and check how it output result in additional information tab.Modify my fuction to achieve desire result. –  Ravs Jun 5 '13 at 15:06
    
which plugin are you using for that info (showing in image)? –  Ravs Jun 5 '13 at 15:28
    
I sm only using Woocommerce plugin. –  gil hamer Jun 5 '13 at 20:41
    
I want to ask one thing in what range your credit lies means( 1 to 100 or upper) –  Ravs Jun 5 '13 at 20:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.