How to Customizing product prices and cart prices in WordPress

How to Customizing product prices and cart price in Wordpress

This code used for Customizing product prices and cart price, and this code add your function.php file WordPress.

WooCommerce Set Custom Product Price When Adding To Cart – In this product, we’ll see how we can override the price of the product when adding the product into the cart.

<?php
add_filter('woocommerce_get_price', 'product_custom_price', 10, 2);
function product_custom_price($price, $product) {
 $custom_price_add = get_post_meta($product->id, 'addprice', true);
 $custom_price = $product->get_regular_price();
 $addprice_new = ($custom_price*$custom_price_add)/100;
 
 if(!empty($custom_price_add)){
  return $custom_price + $addprice_new;
    } else {
       return $custom_price;
    }
}
?>
Learn Tutorials Point
We Well organized and easy-to-understand Interactive tutorials With lots of examples of how to use Tutorials WordPress, PHP, Bootstrap, Bootstrap 4, HTML, CSS, AJAX, jQuery, Woocommerce, Post, Database, Javascript, Theme, Responsive, Templates.

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact us

Fill in the form below or give us a call and we'll contact you. We endeavour to answer all enquiries within 24 hours on business days.