Product markup based on category

[ad_1]

I’m trying to import products and apply a markup to them based on the category it is a part of.

This is the Code I have in the regular price box:

[my_adjust_price({price[1]},{category[1]})]

The code I have in the function editor is as follows:

<?php
function my_adjust_price( $price, $element="" ) {
    $adjust_map = array(
        'Monitors'          => 5.20,
        'Networking' => 1.95,
        'Graphics Cards'               => 4.30
    );

    return ( array_key_exists( $element, $adjust_map ) ) ? ( number_format( $price * $adjust_map[ $element ], 2 ) ) : $price;
}
?>

I’ve followed this link and the solution provided but I’m still having problems and the price doesn’t get adjusted it just returns as blank not zero just straight blank.

  • This topic was modified 7 hours, 33 minutes ago by nafalan.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer