X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (X-Cart 5) (https://forum.x-cart.com/forumdisplay.php?f=56)
-   -   Required Option/Attribute (https://forum.x-cart.com/showthread.php?t=77000)

neroag 06-10-2019 05:24 AM

Required Option/Attribute
 
Is there a way to have a products option a required field ?

I had this on V4 with some java scripting but not sure with V5

many thanks

Ed B. 07-13-2019 10:09 AM

Re: Required Option/Attribute
 
This is about 5.3, and I don't know about in other versions. A quick look at the php code shows that there is an array defined in classes/XLite/View/FormModel/Product/Info.php called
Code:

$schema
So if you want to make required, for example, images, then you would want to set

Code:

$schema[self::SECTION_DEFAULT]['images']['required'] = true;
            $schema[self::SECTION_DEFAULT]['images']['constraints']['Symfony\Compon
ent\Validator\Constraints\NotBlank'] = [
                'message' => static::t('This field is required'),
            ];

Now, unfortunately I don't know if there is a method defiend somewhere for changing this array.

cflsystems 07-13-2019 04:11 PM

Re: Required Option/Attribute
 
It is a setting already in admin cart settings. It is global for all options/variants. If you need it on per product basis you need to get it custom coded.


All times are GMT -8. The time now is 07:38 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.