News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Stop Custom Field from adding Into Total Product Price Shown Until added To Cart

Started by hotrod, August 06, 2026, 02:14:22 AM

Previous topic - Next topic

hotrod

I had this issue a few years back.. And someone gave me a file to change to stop my custom field from adding into the total seen on the product page. 

I since Subscribed and updated to the latest VM and have lost that setting.   We have an oversize shipping fee on some large parts.  Its a custom Field OverSize Shipping. But it's adding to the product price.. making it seem higher that I should be selling it for. If I uncheck Automatically add empty option..  It doesn't had to the total unless checked.. but then the customer has to select it.. and can elect not to...  I need it to add when added to the cart..  and it then says as it still does. Over size shipping fee added into total.  I know Someone here gave me the file and fix.. just can't find it..

In the image below the cost of the radiator is $675  and over size shipping is $135   I can't have it adding into the price people are looking at...

I put a ticket in but I'm sure max is Busy...


VirtueMart 4.6.8 11258
J 4.4.14
PHP 8.232
Bronze Member
VirtueMart 4.6.8 11258
Joomla!  ‎4.4.14
PHP 8.2

hotrod

SOLVED!!!    with hours of work with AI..  I made this change years ago and after updating I lost it... and Of course I didn't document it...

After comparing the old working VirtueMart files against the new version, the behavior change came from administrator/components/com_virtuemart/models/product.php.


Around line 3357 (VirtueMart 4.6.8):

if (VmConfig::get('calculateVariantsOnFreshLoad', true)) {

    $setvirtuemart_custom_id = array();

    foreach ($product->customfields as $customfield) {

        if (!isset($setvirtuemart_custom_id[$customfield->virtuemart_custom_id])) {

            if (empty($customfield->addEmpty)) {

                $product->customPlugin[$customfield->virtuemart_product_id][$customfield->virtuemart_custom_id]
                    = (int)$customfield->virtuemart_customfield_id;

                $setvirtuemart_custom_id[$customfield->virtuemart_custom_id] = 1;
            }
        }
    }
}
The test

I changed:

if (VmConfig::get('calculateVariantsOnFreshLoad', true)) {

to

if (VmConfig::get('calculateVariantsOnFreshLoad', false)) {

(or temporarily if (false) just to verify the behavior).

Result

The product page immediately returned to the old behavior:

✅ Base product price is shown on page load.
✅ Default dropdown option remains selected.
✅ The +$75 is not added to the displayed product price.
✅ After clicking Add to Cart, the +$75 is correctly added to the cart total.
✅ Existing cart calculations continue to work correctly.

Couldn't get help anywhere..  The issues was I have very competitive prices.. others add the fee in shipping I am forced to add as an up-charge.. but with it adding to the total.. google was showing the total with the upcharge which made us look way more expensive..  Posting here for other that would like this option...  and for my records in futur updates..   

Would be useful I think as an option.. for those needed an up-charge attribute on their products...
Bronze Member
VirtueMart 4.6.8 11258
Joomla!  ‎4.4.14
PHP 8.2