Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.82 KB | None | 0 0
  1. add_filter( 'woocommerce_get_price_html', 'custom_price_html', 100, 2 );
  2. add_filter( 'woocommerce_cart_item_price', 'custom_price_html', 100, 2 );
  3. function custom_price_html( $price, $product )
  4. {
  5.     global $post;
  6.     $sales_price_to = get_post_meta($post->ID, '_sale_price_dates_to', true);
  7.     $sales_price_from = get_post_meta($post->ID, '_sale_price_dates_from', true);
  8.  
  9.     if($sales_price_to != "")
  10.     {
  11.         setlocale(LC_TIME, 'pt_PT');
  12.         $sales_price_date_to = strftime('%d %b', $sales_price_to);
  13.         $sales_price_date_from = strftime('%d %b', $sales_price_from);
  14.  
  15.         return str_replace( '</ins>', ' </ins> <div class="promotion-text">De '.$sales_price_date_from.'. até '.$sales_price_date_to.'.</div>', $price );
  16.     }
  17.     else
  18.     {
  19.         return apply_filters( 'woocommerce_get_price', $price );
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement