News:

Support the VirtueMart project and become a member

Main Menu

GENERAL QUESTION: Weight of custom fields

Started by servlet, January 26, 2017, 16:31:02 PM

Previous topic - Next topic

Studio 42

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)

Milbo

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Studio 42

#17
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.


eliotrayner

#18
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


Studio 42

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.

eliotrayner

Hi Studio 42,

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

thanks

servlet

Is there any development for Weight of custom fields
Он-лайн магазин за фототапети http://mishelfoster.com

Studio 42

Quote from: servlet on May 19, 2018, 14:44:23 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.

servlet

Он-лайн магазин за фототапети http://mishelfoster.com

Studio 42

What is your need, A dropdown, a checkbox ...?

servlet

Он-лайн магазин за фототапети http://mishelfoster.com

Studio 42


AH

Yes it does - but it doe not support stock control on VM
Regards
A

Joomla 3.10.11
php 8.0

Milbo

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.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/