Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author myCred

    (@designbymerovingi)

    Hi.

    To do this, your stores currency must be set to anything but Points.

    So if your store is set to use USD, then you can set an exchange rate for myCRED payments via the gateway settings. If you on the other hand have selected to use “Points” as your main currency, there will be no exchange rate to apply as myCRED handles your points for you.

    The myCRED Store is an example of this where you can buy items either in US Dollars or myCRED Tokens. myCRED Tokens has an exchange rate applied to it to match the US price.

    Thread Starter gtrout

    (@gtrout)

    Thanks for the reply!

    I don’t think this solves my problem, though. I’d really need to offer an alternate price in points along side of a regular USD price. A straight exchange rate won’t work because the exchange rate isn’t the same for all products:
    Product #1: $12.95 or 100 points (exchange .1295)
    Product #2: $9.99 or 200 points (exchange .049)
    Product #3: $13.99 or 300 points (exchange .046)
    Product #4: $65.00 or 600 points (exchange .108)

    We’re trying to use BadgeOS to offer rewards for completion of certain tasks but we want to offer tiered rewards so that users can do one set of tasks for a small prize or save up and do multiple sets for a larger prize.

    Plugin Author myCred

    (@designbymerovingi)

    Ah I see.

    Yeah that will not work with a single exchange rate.

    The only solution would be to add in an option for you to adjust the order cost before myCRED process the payment. You would then need to loop though the order / cart and get the number of points each item costs, add it all up and return that amount back to myCRED.

    Right now there is no filter for this that could help you out with this. I could look into adding it in to the next release though.

    Thread Starter gtrout

    (@gtrout)

    Thanks for taking the time to respond. I don’t think I’ll be able to wait for a new version for my current project, but I’m sure it would be a useful feature for others too! Thanks, again!

    Thank you for the Awesome Plugin. I need to do the same thing @gtrout trying.. is it possible now ??

    Plugin Author myCred

    (@designbymerovingi)

    Hey.

    Yeah I added the mycred_woo_order_cost filter which allows you to adjust how much an order in WooCommerce costs in points.

    The filter gives you access to either the cart or order object so you can calculate the cost either on a product by product basis or just apply a generic exchange rate based on the order total.

    Thank you ONCE AGAIN for this Awesome Plugin.

    I managed to add a custom field to products and as you mentioned above looped through it.it worked fine.

    function addPointsOnPorderSuccuss($order_id) {
    
    	$user_id = get_current_user_id();
    	$order = new WC_Order( $order_id );
    	$items = $order->get_items();
    
    	$totalVp  = 0;
    
    		foreach ( $items as $item ) {
    			$product_id = $item['product_id'];
    			$product_qty = $item['qty'];
    			$vp = get_post_meta($product_id, 'vPoint', true);
    			$vp  = $vp * $product_qty;
    			$totalVp =  $totalVp  + $vp;
    		}
    
    	//echo $totalVp ;
    	if(is_user_logged_in()){
    	mycred_add(  'Order_Complete', $user_id, $totalVp, 'Earned ' . $totalVp . 'vPoints for Order #'.$order_id, $order_id  );
    	}
    }
    
     add_action( 'woocommerce_order_status_complete', 'addPointsOnPorderSuccuss' );

    Using above code i managed to add the points. but now when i am trying to give badges its not working. actually i am bit confused. can you please help me ??

    Plugin Author myCred

    (@designbymerovingi)

    Hey.

    According to your code, you are paying your users under the reference: “Order_Complete”. Since this is a custom reference you will need to add it into the reference list which will allow you to setup a badge with the requirement of having this reference in the log.

    add_filter( 'mycred_all_references', 'mycred_pro_add_custom_refs' );
    function mycred_pro_add_custom_refs( $reference ) {
    
    	$reference['order_complete'] = 'Completed order payment';
    	return $reference;
    
    }

    You can use the mycred_all_references filter to register any number of custom references you might add of your own. Otherwise you can find all references listed in the codex.

    A small side note, you should keep references lowercase as some features in myCRED will make comparisons and these features assumes your ref is lowercase.

    Finally I would change the following:

    if(is_user_logged_in()){

    to:

    if(is_user_logged_in() && function_exists( 'mycred_add' ) ){

    sorry for the late Reply.. been bit busy and THANK YOU VERY MUCH for your support

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘alternate myCRED price for WooCommerce product’ is closed to new replies.