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

Override checkbox default custom field

Started by Kuubs, October 07, 2020, 10:03:58 AM

Previous topic - Next topic

Kuubs

Hello,

I have found that when you add a 1 to the database for the custom fields per product you get a disabled checkbox available in your product to disable the custom field, but not delete it. Because when you delete a custom field that value is also deleted in hte order list, so for example if you have a custom field color and Red is unavailable or sold out, you remove the color red. But that also means that the previously made orders that chose the color red do not have the color red anymore in the order itself.

So my solution was to disable the field rather than removing it altogether. But I can only have that disable checkbox if I have the override set to 1 in the database. Now I do that manually, but I want to add it so the default of the database is 1 rather than zero. Does anyone know how I can achieve this?

I tried changing the default to 1 in the database but it still gets 0 so I think somewhere in the code the making of the custom fields gets put in a 0 instaed of a 1 that I want.

Kuubs

Anyoen has an idea? Maybe overriding the core somewhere?

Studio 42

In this create a customfield plugin so you can manage all this problems yourself.
You can have so many specific cases

Kuubs

Quote from: Studio 42 on October 12, 2020, 17:10:52 PM
In this create a customfield plugin so you can manage all this problems yourself.
You can have so many specific cases

No I literally only have to set the override field in the database to 1. For all custom fields. Where can I do this?

Kuubs

Someone know how to do this? I absolutely need to implement this because it is a vital function right now in my webshops.

Studio 42

Quote from: Huubs on October 15, 2020, 15:48:41 PM
Someone know how to do this? I absolutely need to implement this because it is a vital function right now in my webshops.
You need a custom developement, it's not so easy to do and to explain.
1st is to verify on add to cart that the value is safe(because you cannot compare after if you remove a value a day)
After, because you know that the value is safe, you can directly render the value saved in the database.
You can only do this with a plugin, because you have to use another logic that the core customfield system.

Kuubs

Quote from: Studio 42 on October 21, 2020, 10:41:28 AM
Quote from: Huubs on October 15, 2020, 15:48:41 PM
Someone know how to do this? I absolutely need to implement this because it is a vital function right now in my webshops.
You need a custom developement, it's not so easy to do and to explain.
1st is to verify on add to cart that the value is safe(because you cannot compare after if you remove a value a day)
After, because you know that the value is safe, you can directly render the value saved in the database.
You can only do this with a plugin, because you have to use another logic that the core customfield system.

You are greatly misunderstanding my problem here. When you add a custom field and make a child the override checkbox comes up by default. You can disable the custom field for that specific child product. Now this can be achieved for normal porduct as well by adding a 1 to the override product_custom_field in teh database. Now I want to set this default to 1 so the custom field can be disbaled by the admin in the product overview.

I literally have to add a 1 instead of a 0 in the code, presumably the model code, so that the custom field database row gets inserted with a 1 to the override instead of 0. I tried setting it to default value of 1 in the database but that is not working.

pinochico

If this code is not in core as you want, then for your project need custom developing.
Don't wait answer from the forum - forum is not free developers :)
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds for FB, GMC,.. from products, categories, orders, users, articles, acymailing subscribers and database table
Virtuemart Email Manager - customs email templates
Import products for Virtuemart - from CSV and XML
Rich Snippets - Google Structured Data
VirtueMart Products Extended - Slider with products, show Others bought, Products by CF ID and others filtering products

Kuubs

Quote from: pinochico on October 24, 2020, 13:20:46 PM
If this code is not in core as you want, then for your project need custom developing.
Don't wait answer from the forum - forum is not free developers :)

I dont understand why you guys cannot seem to grasp what I want. I want to make a 0 a 1. I just want to know where the code islocated.

jenkinhill

A zero is entered into the override column as the default value. This is from the installation SQL for the ###_virtuemart_product_customfields table:
`override` int(1) UNSIGNED NOT NULL DEFAULT '0',

For a pre-existing table you can change the default to 1, but this will only be applied for new entries:
ALTER TABLE `###_virtuemart_product_customfields` CHANGE `override` `override` INT(1) UNSIGNED NOT NULL DEFAULT '1';

You can export the database table to change existing entries using a suitable editor (I use NoteTab Pro) and re-import.

There is no code in the core to set overrides to 1 for all entries that I have been able to locate.
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Kuubs

#10
Quote from: jenkinhill on October 26, 2020, 16:59:58 PM
A zero is entered into the override column as the default value. This is from the installation SQL for the ###_virtuemart_product_customfields table:
`override` int(1) UNSIGNED NOT NULL DEFAULT '0',

For a pre-existing table you can change the default to 1, but this will only be applied for new entries:
ALTER TABLE `###_virtuemart_product_customfields` CHANGE `override` `override` INT(1) UNSIGNED NOT NULL DEFAULT '1';

You can export the database table to change existing entries using a suitable editor (I use NoteTab Pro) and re-import.

There is no code in the core to set overrides to 1 for all entries that I have been able to locate.

Thank you!

EDIT: I changed it in the database and if I add a new custom field it does not autoamtically set it to override, it still isnerts a 0 at the new row.

jenkinhill

Hmm the SQL worked on a test site on a subdomain of a live site on my VPS but on Xampp localhost it errors.
#1067 - Invalid default value for 'created_on'

I don't have time to look into this, but I do believe that changing the default value for override could provide a solution.
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum