VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: razor7 on January 29, 2024, 23:41:46 PM

Title: [SOLVED] VM 4.2.6 custom fields errors
Post by: razor7 on January 29, 2024, 23:41:46 PM
Hi! testing 4.2.6 I found an issue with custom fields. I have a select custom field and after changing the value, the url of the page gets the field value (not the real url) and the page doesn't change at all. I have found some changes in cvfind.js and customfield.php sub layout, here I publish my changes so the dev team can consider them.

cvfind.js

Change this
    //We check first if it is a radio
    jQuery(container).find('input[data-cvselection="true"]:checked').each(function() {
        selection[selection.length] = jQuery(this).val();
        found = true;
    });
    if(!found){
        jQuery(container).find('input[data-cvselection="true"]').each(function() {
            selection[selection.length] = jQuery(this).val();
        });
    }

To this...
    //We check first if it is a radio
    jQuery(container).find('[data-cvselection="true"]:checked').each(function() {
        selection[selection.length] = jQuery(this).val();
        found = true;
    });
    if(!found){
        jQuery(container).find('[data-cvselection="true"]').each(function() {
            selection[selection.length] = jQuery(this).val();
        });
    }

customfield.php
Change this
                        $attribs['data-cvsel'] = 'field' . $customfield->virtuemart_customfield_id ;
                        $fname = $fieldname.'['.$k.']';

To this
                        $attribs['data-cvsel'] = 'field' . $customfield->virtuemart_customfield_id ;
                        $attribs['data-cvselection'] = 'true';
                        $fname = $fieldname.'['.$k.']';

Also in this file, for some reason, if I get Itemid=0 in the url, it adds that 0 to the product ID, so, change this
                    $Itemid = vRequest::getInt('Itemid',''); // '&Itemid=127';
                    if(!empty($Itemid)){
                        $Itemid = '&Itemid='.$Itemid;
                    }

To this...
                    $Itemid = vRequest::getInt('Itemid',''); // '&Itemid=127';
                    if(!empty($Itemid)){
                        $Itemid = '&Itemid='.$Itemid;
                    } else if ($Itemid !== '') {
                        $Itemid = '';
                    }
Title: Re: VM 4.2.6 custom fields errors
Post by: Milbo on February 06, 2024, 20:20:11 PM
Thank you for your work. I think you send me that via skype, right? That should be enhanced your way in the new version. Please check
Title: Re: VM 4.2.6 custom fields errors
Post by: razor7 on February 09, 2024, 03:04:43 AM
Sorry Milbo, I don't even have Skype installed, but maybe another guy found this issue and sumbited similar fix.