We are running a webstore (with Woocommerce on Wordpress) with high-end prices and of course then we have installment plans. I like to show this on the product page itself (namely before "add to cart form"). And I made this simple custom code which should calculate month-to-month price, however what I receive on the page is a stop in the code before "add to cart form" so there is an error here, but I cannot see it.
Is there anybody out there who can help me or point me in a direction? Really appreciate it!
By the way, no interest rate when the installment plan is 12 months or less. That's why I did not include interest rate.
(Code has been edited to reflect solution to the problem)
// Price per month
add_action( 'woocommerce_before_add_to_cart_form', 'price_per_month', 5 );
function price_per_month() {
global $product
$price = $product->get_price();
$price = $price + 295;
$months = 12;
$fee = 39;
//$register_fee = 295;
$price_per_month = ($price / $months);
$total_per_month = $price_per_month + $fee;
echo "
<div id='ppm-container'>
<div id='ppm-text'>
Pay from only ". $total_per_month ." NOK per month.
</div>
</div>
";
}
Few things
First you need to have
global $product
Second, Use WP_DEBUG in order to see errors