Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if ( function_exists( 'mymail_add_tag' ) ) {
- function my_unitprice_function($option, $fallback, $campaignID = NULL, $subscriberID = NULL){
- $_pf = new WC_Product_Factory();
- //relative products
- if($option < 0){
- $posts = get_posts( array(
- 'numberposts' => 1,
- 'post_type' => 'product',
- 'offset' => $option,
- ) );
- $post_id = (int) $posts[0]->ID;
- //absolute products
- }else{
- $post_id = (int) $option;
- }
- $_product = $_pf->get_product($post_id);
- $price_per_unit = $_product->get_price() / get_post_meta ($post_id, 'sub_title', true );
- return '$'.number_format(round($price_per_unit,2),2);
- }
- mymail_add_tag('unitprice', 'my_unitprice_function');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement