News:

Support the VirtueMart project and become a member

Main Menu

Simple VM4 Product Cart Variant Custom Field / Attribute Plugin [ FREE ]

Started by AH, December 20, 2014, 10:53:56 AM

Previous topic - Next topic

gap

Quote from: AH on April 16, 2021, 10:35:49 AM
Hi again
In VirtueMart 4.0.12 10777, if you combine this qvariant plugin with "Generic Child Variant" then the 2nd, 3rd and next items of the very same parent product cannot be added properly to the cart: no custom fields of the next products and basic price only. I use the last version of QVARIANT.

Example:
1. custom field (Generic child variant on short desc): COLOR (gold, red, blue etc)
2. custom field qvariant: size in mm (50 mm : € 20; 100mm: € 30 etc)

problem:
First you add one item, for example red 150 mm. RESULT: Cart shows custom fields and price properly
Afterwards you add a second item. For example: blue, 300 mm. RESULT in the cart: 1st item: all OK. 2nd item: NO custom fields showed and the basic price (€ 20) appears instead of modifed price.

There have been a general problem of VM customfields in the cart in the past. If you comment the line
unset($productIds[$k]);
in customfields.php as it was suggested, I get even bigger problems!
I got custom field group multiplying in category view! (some products in category has the same parents and their custom fields start to multiply. 1st product: normal. 2nd: double custom fields. 3rd: triple custom fields.


This problem of not showing custom fields in the cart appear in case of products where there is a combination of QVARIANT and VM built-in custom field in one product. I tested it with multiple variant but it gave the same bug in the cart.

How to fix this?

gap

I figured out that downgrading customfields.php to VM 3.8.8 version solves this problem.

gap

Quote from: gap on August 08, 2023, 09:00:33 AM
I figured out that downgrading customfields.php to VM 3.8.8 version solves this problem.

And however it works on my site, of course it is not fully compatible and gives an error by saving a product with customfields:
vmError: Plugin plgVmCustomSpecification must be updated, called in vmcustomplugin.php OnStoreProduct

AH

Many thanks for the detailed posts.

I will look to see why the qvariant is having an issue with core vm and may post a fix at some point.
Regards
A

Joomla 4.4.5
php 8.1

gap

Hi guys

I had the problem that the sku modifier code added the modifying string to the sku multiple times.
You can fix this in qvariant.php in line 211.
old code

## code removed until submitter shows configuration see below for correct configurations

AH

That does not appear to be a valid change to the code. 

Please show the configuration that you had and the error that it gives.

Here are 2 sample configurations:-
This config option has two @'s for every choice, the data following the second @ is used to append to the original item sku:-

5m@*5@5m,6m@*6@6m,7m@*7@7m,8m@*8@8m

For an original sku of 31QU[/b}

This gives cart sku's of:

31QU-5m
31QU-6m
31QU-7m
31QU-8m



This config option has two @'s except for every choice except for 7m:

5m@*5@5m,6m@*6@6m,7m@*7,8m@*8@8m,9m@*9@9m

For an original sku of 31QU[/b}

This gives cart sku's of:

31QU-5m
31QU-6m
31QU
31QU-8m


Regards
A

Joomla 4.4.5
php 8.1

AH

This plugin has been tested and is working with Joomla 4/5 and VirtueMart 4 latest releases
Regards
A

Joomla 4.4.5
php 8.1

denism300

It's a great plugin, but I found 2 problems.:
1. Layout overriding does not work.
2. If radio buttons are selected in the settings, the checked property is added to the first element during rendering, however, the product price is not recalculated.

fasterjoomla

Thank you @AH great plugin!
The language format is now incompatible with Joomla 5.3.3, it just wouldn't load any translations at all. Newlines are no longer allowed in the ini files.

I simply removed all space from VMCUSTOM_QVARIANT_EXAMPLES and it works like a charm.

I cannot upload the updated file, just remove all newlines in the string VMCUSTOM_QVARIANT_EXAMPLES in en-GB.plg_vmcustom_qvariant.ini and empty en-GB.plg_vmcustom_qvariant.sys.ini as it's not used in the name or description.

The file en-GB.plg_vmcustom_qvariant.ini should look like this:

; QUORVIA from original idea by Banquet Tables Pro
; Copyright (C)  QUORVIA. All rights reserved.
; License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php
; Note : All ini files need to be saved as UTF-8 - No BOM
VMCUSTOM_QVARIANT ="Customfield Product variant selection"
VMCUSTOM_QVARIANT_INS ="Product variant selection options"
VMCUSTOM_QVARIANT_STRING = "Product variant options"
VMCUSTOM_QVARIANT_CONFIG_LABEL = "Usage and config"
VMCUSTOM_QVARIANT_EXAMPLES = "<br/>Structure - <b>t@mv,</b><br/><br/><b>t</b> = Item variant - Product variant selection text and Item variant text that will show in cart <br/> Language keys can be used for the Title and Variants e.g. COM_MY_OPTIONS  -  COM_RED,COM_YELLOW you need to add these to your language overrides files <br/><b>@</b> = separates the modifier from the selection text - If there are no additional modifiers nothing else is needed <br/><b>m</b> = modifier either + - * or = <br/><b>v</b> = modifier value <br/><b>,</b> = separates variants <br/><br/><br/>1. <b>Simple selections no price adjust</b> &nbsp;&nbsp;&nbsp;&nbsp;Config: <b>Red,Green,Blue</b>&nbsp;&nbsp;&nbsp;&nbsp;All variants are at Retail <br/><br/>2. <b>Adjust the price + or - </b> &nbsp;&nbsp;&nbsp;&nbsp;Config: <b>Sml,Med@+1,Lrg@+2</b>&nbsp;&nbsp;&nbsp;&nbsp;Give prices of: Sml = Retail, Med = Retail +1, Lrg = Retail +2 <br/><br/>3. <b>Multiply the price * </b> &nbsp;&nbsp;&nbsp;&nbsp;Config: <b>1m,2m@*2,3m@*3</b>&nbsp;&nbsp;&nbsp;&nbsp;Gives prices of: 1m = Retail, 2m = Retail * 2, 3m = Retail * 3 <br/><br/>4. <b>Sell fixed multiples * </b> &nbsp;&nbsp;&nbsp;&nbsp;Config: <b>2kg@*2,4kg@*4,6kg@*6</b>&nbsp;&nbsp;&nbsp;&nbsp; <br/><br/>5. <b>Fix the price of a variant = </b> &nbsp;&nbsp;&nbsp;&nbsp;Config: <b>Red,Green,Blue@=12.50</b>&nbsp;&nbsp;&nbsp;&nbsp;Gives prices of: Red Green = Retail, Blue = 12.50 <br/><br/>6. <b>Append a string to the sku = </b> &nbsp;&nbsp;&nbsp;&nbsp;Config: <b>Sml@@sml,Med@+1@med,Lrg@+2@lrg</b>&nbsp;&nbsp;&nbsp;&nbsp;Give SKU's of: SKU: origsku-sml, origsku-med, origsku-lrg <br/><br/>7. <b>Change the cart weight for variant = </b> &nbsp;&nbsp;&nbsp;&nbsp;Config: <b>Sml,Med@@@2,Lrg@@@4</b>&nbsp;&nbsp;&nbsp;&nbsp;Give cart weight of: Sml = product weight, Med = 2, Lrg = 4 <br/><br/>8. <b>Product variant selections can be a set of mixed types if required</b>&nbsp;&nbsp;&nbsp;&nbsp;Config: <b>Sml@*2,Med@+12,Lrg@-2</b> "
VMCUSTOM_QVARIANT_WEIGHT = "Adjust product weight for options using Multiply modifier * - <br>Note: Setting a 'Change the cart weight for variant' will override this for that specific variant"
VMCUSTOM_QVARIANT_WEIGHT_MULTIPLIER = "This is useful for shipping. The weight of the single product will be multiplied by the price multiplier e.g. product-weight * 3.  Setting a weight for a variant will override this - desc@pricing@skumod@weightset"
VMCUSTOM_WEIGHT_NO = "No "
VMCUSTOM_WEIGHT_YES ="Yes"
VMCUSTOM_QVARIANT_IS_RADIO = "Show options as a Radio list"
VMCUSTOM_QVARIANT_IS_RADIO_DESC = "Use a Radio list for the product variants rather than a drop down selection.<br/> <b>Note that this is likely to be unsuitable for a large quantity of options.</b>"
VMCUSTOM_IS_RADIO_NO = "No"
VMCUSTOM_IS_RADIO_YES = "Yes"
VMCUSTOM_QVARIANT_MULTIPLIER_PRICE = "Show price when using a Multiply modifier"
VMCUSTOM_QVARIANT_MULTIPLIER_PRICE_DESC = "Show the price of the option next to the option when using a Multiply modifier *.</b>"
VMCUSTOM_MULTIPLIER_PRICE_NO = "No"
VMCUSTOM_MULTIPLIER_PRICE_YES = "Yes"