VirtueMart Forum

VirtueMart 2 + 3 => Product creation => Topic started by: servlet on January 26, 2017, 16:31:02 pm

Title: GENERAL QUESTION: Weight of custom fields
Post by: servlet on January 26, 2017, 16:31:02 pm
I found there is no option to calculate weight of selected custom fields of product to calculate correct shipping price.

How to calculate weight of this product:

Material: Canvas, Art Textile (1 kg, 1.5 kg)
Subframe: Without subframe, With subframe (0 kg, 1 kg)
Frame: Simple slim frame, Medium gold frame, Large art frame. (1 kg, 2 kg, 3 kg)

How VM calculate weight for print reproduction or something similar where there is weight for every custom field.

If you have selection as: Canvas + Without subframe + Simple slim frame = 1 + 0 + 1 = 2 kg.
If you have selection as: Art Textile + With subframe + Large art frame = 1.5 + 1 + 3 = 5.5 kg

Title: Re: GENERAL QUESTION: Weight of custom fields
Post by: Studio 42 on January 27, 2017, 02:40:59 am
you need to write own plugin
Title: Re: GENERAL QUESTION: Weight of custom fields
Post by: servlet on January 27, 2017, 07:34:20 am
Plugin for custom fields or other?
Title: Re: GENERAL QUESTION: Weight of custom fields
Post by: Studio 42 on January 27, 2017, 13:18:16 pm
A customfield plugin.
You have a plugin in the forum that can change the weight per option. But i cannot find it
Title: Re: GENERAL QUESTION: Weight of custom fields
Post by: servlet on January 29, 2017, 18:08:29 pm
This is a good news, but how can I find it?
Title: Re: GENERAL QUESTION: Weight of custom fields
Post by: lindapowers on January 29, 2017, 20:36:59 pm
The only one I know that modifies weight is this one https://forum.virtuemart.net/index.php?topic=127362.0 but that one doesn't work as you or me needed.

From your example what you require is basicly the "String type" custom field with weight option per variant.
This could add options like: 1 kg 2 kg 3 kg without having to create child or multivariants and is so much simple to add string custom fields than childs or multivariants.

If the product is the same is quite nonsense having to create multivariants or childs just for weight variants.

Some could argue  that each user could request any other field there added and is true however the weight is something very common to be applied to shipping costs and there are many weight dependent shipments in all countries.

For now what we use is child products since we have no other option, luckily we don't have that many products which are the same but with different weight variants, even in some products we ended up adding only one variant as main product due to this limitation.
Title: Re: GENERAL QUESTION: Weight of custom fields
Post by: servlet on January 29, 2017, 21:23:26 pm
Thank you for info @lindapowers
I know about this extension. In this topic ones of latest comments are mine... ;)

As you, I am using one weight for hole product. I am using heaviest variant of product, but it is no correct for the customer. He will pay more.

I hate multivariants or child product.

I have more than 10 000 variants per 1 product via custom fields selection. If I have to build 10 000 child products for every head product I will die before do this. From other side database will be extremely heavy.

I am just kidding what will cost to be builded such custom filed plugin with weight calculation
Title: Re: GENERAL QUESTION: Weight of custom fields
Post by: lindapowers on January 29, 2017, 23:03:36 pm

As you, I am using one weight for hole product. I am using heaviest variant of product, but it is no correct for the customer. He will pay more.


Ah my friend I understand perfectly, we did that also some time ago but it is indeed not fair for the customer and even for you if you export the calculated weight it will show incorrect values.

In our case it was only a few products so we could live without them or were added as childs but for your case you really need that function indeed, ask the VM team or Patrick (Studio 42). Pretty sure this can be done to satisfy your needs, is just a matter of variants with the weight value added or creating 10 000 childs which doesn't seem very nice solution.
Title: Re: GENERAL QUESTION: Weight of custom fields
Post by: Studio 42 on January 30, 2017, 01:30:39 am
Thanks Manu, it was the plugin i searched for ;)
You need to explain, the problem for your variant and why this plugin do not work for you?
For a customer that sold Home portal, i wrote a price table(2 options height and width), this is generic for all products using this matrix, so you don't have to manage the prices variants for each products.
So if you have always the same options for many product, it's possible to use generic options for all so in your database you have only 1 customfield declared per products and the whole datas are in only one customfield.
If you need 4 or 5 different generic datas, you can of course declare the customfield 4 or 5 times or more.
So for my customer he had 6 variants  generic price table customfield for only 86 products and have only this to manage for all portals else he had to add more then  7400 multivariant using childs.
And i have do same for the colors, because he use always 6 same colors for all
Title: Re: GENERAL QUESTION: Weight of custom fields
Post by: Milbo on January 30, 2017, 10:19:37 am
lol, why the heck have you so much problems with childs? There is no performance problem or so, the child is one table, one line, the customfield would be one table, one line. There is noo difference, guys, really.

Our plugin also calculates the weight http://extensions.virtuemart.net/products/custom-size-detail
You can set a dropdown as input, so you get exactly what you want (without children)
Title: Re: GENERAL QUESTION: Weight of custom fields
Post by: servlet on January 30, 2017, 10:36:11 am
Milbo, will you fill manually 10 000 lines per one product where every product has different values. I dont think so... You will prefer to fill 50 custom fields instead 10 000 child products... Child products are for small stores or for simple products...

By the way I Asked a question about CUSTOM SIZE plugin via extension.virtuemart.net but there is no response to this moment. Other vendors replay me up to 1 day but for the VM core extensions nothing...
Title: Re: GENERAL QUESTION: Weight of custom fields
Post by: Milbo on January 30, 2017, 13:12:04 pm
lol
no, man, you just do not child products. IT is EXACTLY the opposite. Child products are developed for stores with more than 100.000 products, you funny guy.

I think you really have no clue about, how they work, eh? Just an example.

A normal product loads
The product table
the product language table (up to three!)
the product pricing table
the product categories table
the product manufacturers table
the product medias table
the product customfields

a simple child product loads ONLY the product table, do you get the difference?

uhm, when did you write to extensoins? Matej my supporter is ill since 3 weeks. So when you wrote about email, it may slipped through, http://extensions.virtuemart.net/ticket
Title: Re: GENERAL QUESTION: Weight of custom fields
Post by: Studio 42 on January 30, 2017, 13:30:04 pm
lol, why the heck have you so much problems with childs? There is no performance problem or so, the child is one table, one line, the customfield would be one table, one line. There is noo difference, guys, really.

Our plugin also calculates the weight http://extensions.virtuemart.net/products/custom-size-detail
You can set a dropdown as input, so you get exactly what you want (without children)
I'm not really sure that having 200 childs have better performance that one price table ?
first, you need to get all products and set it before, one by one and use multi variant.
Compared to a price table you only have to set the list and get the index and don't need to reload full products on option changes.
Of course if you have many fields to use, a moment it's better to use child, but if you only have to use 2 or 3 fields per variant, i think that it's certainly 100 time faster and certainly more.
Title: Re: GENERAL QUESTION: Weight of custom fields
Post by: servlet on February 01, 2017, 10:50:43 am
Thank you Milbo
I get difference...

However I need weight in custom fields :)
I will research for your extension CUSTOM SIZE
Title: Re: GENERAL QUESTION: Weight of custom fields
Post by: Milbo on February 01, 2017, 23:40:05 pm
I'm not really sure that having 200 childs have better performance that one price table ?
Childs deliver exactly that, you can have 200 products with ONE price row.

first, you need to get all products and set it before, one by one and use multi variant.
Basic concept of VM. Pattern have NOTHING todo with Multivariant or generic child variants.

Compared to a price table you only have to set the list and get the index and don't need to reload full products on option changes.
Of course if you have many fields to use, a moment it's better to use child, but if you only have to use 2 or 3 fields per variant, i think that it's certainly 100 time faster and certainly more.


Our customsize plugin does that. You can enter values which create a dropdown and set a factor between the size (m,m²,m³ for example). So it calculates directly the correct weight. the big reason for vm3 actually. In vm2 it was not possible to do this clean.
Title: Re: GENERAL QUESTION: Weight of custom fields
Post by: Studio 42 on February 01, 2017, 23:49:21 pm
Of course, in VM2 you was not able to do it natively, because some trigger was missing but remember what was all the TODO in vm2. in customfields as in payment and shipment plugins
Note that a trigger in VM3 is not right, the stockUpdate trigger, because it's not possible to modify general quantity, you have to fully rewrite the stock update in the plugin.
Eg, if you have a plugin that need to handle on order state change 5 in stock for 1 quantity in the order or cart, main quantity before stock update cannot be set from plugin(note: i don't checked in last 3.0.19)
Title: Re: GENERAL QUESTION: Weight of custom fields
Post by: Milbo on February 03, 2017, 09:34:04 am
trigger updateStatusForOneOrder ?
Title: Re: GENERAL QUESTION: Weight of custom fields
Post by: Studio 42 on February 03, 2017, 13:51:11 pm
I mean in function handleStockAfterStatusChangedPerProduct($newState, $oldState,$tableOrderItems, $quantity) {

line $dispatcher->trigger('plgVmGetProductStockToUpdateByCustom',array(&$tableOrderItems,$param, $productCustom)); have not the quantity, so it's not possible to change main quantity.
In my cas for eg. It's for "electronic kits", so the main quantity change is "0" because the elements in the kit use completly different products.
So in the called handleStockAfterStatusChangedPerProduct product, the quanitty change is "0", but for the elements in the kit, quantity change depending the custom field.
So the right way for me is to use
$dispatcher->trigger('plgVmGetProductStockToUpdateByCustom',array(&$tableOrderItems,$param, $productCustom,&$quantity));
then you can change quantity by plugin if needed and not have to rewrite completly the same function for order statut (copy paste with some changes).
Another problem is that $newState, $oldState is not send to plugins so you cannot easy veriify what to do and have to get order status another way.

Title: Re: GENERAL QUESTION: Weight of custom fields
Post by: eliotrayner on May 16, 2018, 13:25:58 pm
Hi Studio 42

Did you get anywhere with this? I am trying to do a similar thing in VM 3.2.12 aka alter quantity and id of product to have stock updated.

I am also using ... $dispatcher->trigger('plgVmGetProductStockToUpdateByCustom',array(&$tableOrderItems,$param, $productCustom,&$quantity));

thanks
Eliot

Title: Re: GENERAL QUESTION: Weight of custom fields
Post by: Studio 42 on May 16, 2018, 18:05:53 pm
Hi, i dont checked, if the core has change, i wrote the updater manually, but this need a big code for nothing, only because quantity do not exist.
Title: Re: GENERAL QUESTION: Weight of custom fields
Post by: eliotrayner on May 16, 2018, 18:41:40 pm
Hi Studio 42,

I also wrote my own updater but it was a good pointer for me adding in the &$quantity

thanks
Title: Re: GENERAL QUESTION: Weight of custom fields
Post by: servlet on May 19, 2018, 14:44:23 pm
Is there any development for Weight of custom fields
Title: Re: GENERAL QUESTION: Weight of custom fields
Post by: Studio 42 on May 19, 2018, 20:05:59 pm
Is there any development for Weight of custom fields
It's possible to change weight using a product customfield plugin but not with Virtuemart core custom fields.
Title: Re: GENERAL QUESTION: Weight of custom fields
Post by: servlet on May 20, 2018, 07:57:02 am
Ok, but which one?
Title: Re: GENERAL QUESTION: Weight of custom fields
Post by: Studio 42 on May 20, 2018, 10:47:45 am
What is your need, A dropdown, a checkbox ...?
Title: Re: GENERAL QUESTION: Weight of custom fields
Post by: servlet on May 20, 2018, 12:47:04 pm
Dropdown, thank you
Title: Re: GENERAL QUESTION: Weight of custom fields
Post by: Studio 42 on May 20, 2018, 16:27:20 pm
Check here https://forum.virtuemart.net/index.php?topic=127362.0, if i'm right, it support weight parameters.
Title: Re: GENERAL QUESTION: Weight of custom fields
Post by: AH on May 21, 2018, 09:27:51 am
Yes it does - but it doe not support stock control on VM
Title: Re: GENERAL QUESTION: Weight of custom fields
Post by: Milbo on May 29, 2018, 15:56:57 pm
https://extensions.virtuemart.net/product/products/custom-size-detail

has also a method to set the weight.

line $dispatcher->trigger('plgVmGetProductStockToUpdateByCustom',array(&$tableOrderItems,$param, $productCustom));

imho the $tableOrderItems has the weight.