News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Pre-set shopper field on checkout programmatically

Started by vmfyelloq19, July 22, 2019, 09:04:55 AM

Previous topic - Next topic

vmfyelloq19

Hi folks,

I need so set the value of a shopper field on particular conditions (weekday is saturday or sunday, in this case).
I've made a joomla system plugin hooking to the plgVmDisplayLogin() event as this looked the best matching event.

As far I found out that I can get all shopper fields, including custom ones with $cart=VirtueMartCart::getCart(false)
Both $cart->BTaddress and $cart->STaddress contain all fields, while $cart->BT, $cart->ST and $cart->cartfields only custom shopper fields plus tos and customer_note.
Checking joomla's virtuemart session namespace, I see ->BT, ->ST and ->cartfields as well.

Still, no matter what data I try to modify, it does not show up in the checkout form.

I tried to set values directly into joomla's session and $cart->getCart() afterwards, also tried $cart->loadCart($session_data_jsondecoded) as well as  $session->set(...) to virtuemart session namespace.

Any hints?

TIA!


Studio 42

You can create a vmuserfield.
It's not the best sample but you have 1 in core : realex_hpp_api

vmfyelloq19

Hi Studio 42,

thank you for your reply. Had a quick look at realex_hpp_api. Just to be sure I'm not mixing up general plugin requirements with realex_hpp_api specific stuff: I'm I right I need my own tables to store my particular single value?

Also, will the field, if required, be checked via javascript like virtuemart's own fields?

TIA!

Studio 42

See http://forum.virtuemart.net/index.php?topic=141335.0, you can use parameters, but it's not directly set/get in the core
I know that doc is missing(since 7 year), i think that this type of plugin is not many used(and can be so powerful)
Most plugin triggers are in JOOMLAROOT/administrator/components/com_virtuemart/models/userfields.php
Search for $dispatcher->trigger in this file to find the function name and parameters

vmfyelloq19

Hi Studio 42,

thanks for hinting to the forum entry. I'll check it out.