Author Topic: Override checkbox default custom field  (Read 1102 times)

Huubs

  • Jr. Member
  • **
  • Posts: 285
Override checkbox default custom field
« on: October 07, 2020, 10:03:58 am »
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.

Huubs

  • Jr. Member
  • **
  • Posts: 285
Re: Override checkbox default custom field
« Reply #1 on: October 12, 2020, 10:54:59 am »
Anyoen has an idea? Maybe overriding the core somewhere?

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4405
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: Override checkbox default custom field
« Reply #2 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

Huubs

  • Jr. Member
  • **
  • Posts: 285
Re: Override checkbox default custom field
« Reply #3 on: October 13, 2020, 09:24:21 am »
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?

Huubs

  • Jr. Member
  • **
  • Posts: 285
Re: Override checkbox default custom field
« Reply #4 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.

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4405
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: Override checkbox default custom field
« Reply #5 on: October 21, 2020, 10:41:28 am »
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.

Huubs

  • Jr. Member
  • **
  • Posts: 285
Re: Override checkbox default custom field
« Reply #6 on: October 24, 2020, 10:53:00 am »
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

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 895
    • MiniJoomla
  • Skype Name: support-easysoftware
  • VirtueMart Version: 3
Re: Override checkbox default custom field
« Reply #7 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 :)
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds from products, orders and database table
Virtuemart Email Manager - customs email templates

Huubs

  • Jr. Member
  • **
  • Posts: 285
Re: Override checkbox default custom field
« Reply #8 on: October 26, 2020, 12:16:48 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

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 28016
  • Always on vacation
    • Jenkin Hill Internet
Re: Override checkbox default custom field
« Reply #9 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.
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

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

Currently using VirtueMart 3.8.7 10374 on Joomla 3.9.24 PHP 7.4.12

Huubs

  • Jr. Member
  • **
  • Posts: 285
Re: Override checkbox default custom field
« Reply #10 on: October 27, 2020, 16:40:52 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

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 28016
  • Always on vacation
    • Jenkin Hill Internet
Re: Override checkbox default custom field
« Reply #11 on: October 27, 2020, 18:21:51 pm »
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

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

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

Currently using VirtueMart 3.8.7 10374 on Joomla 3.9.24 PHP 7.4.12