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

manipulating stored attributes in custom plugin

Started by sprachrohr, September 05, 2016, 12:56:34 PM

Previous topic - Next topic

sprachrohr

Hallo,

i developed a product configurator as a custom Plugin. There are lots of configurable options which depend on each other. Only a few of them are relevant for the order.

Now i have the problem, that all possible options are stored in the order_items table (field product_attribute). For me it is necessary that only the relevant attributes are stored.

Is there in custom Plugin a function/hook for manipulating the stored attributes?

Thanks for your answer!

Best regards
Dirk

Studio 42

function plgVmPrepareCartProduct ?
But i think you need to modify cart session.
But why have you unwanted values. When i display the inputs in the product, i only use needed fields, so i have not to manipulate the session after.

sprachrohr

thanks for your answer...

i think i have to explain in detail.

my configurator has a huge form containing a lot of inputs which depend on each other. so not every input is used everytime. the display of the inputs is controlled by javascript.

It is one VM product called ,,configurator". It has an input field called ,,product" (containing 5 products). The other input fields depend on the product selection. Some fields belong to all products, some fields belong only to one product.

the user has the ability to make some configurations and then switch between these products. its quite cool because you can see how your configuration looks on different products. For this feature i think i have to keep all input fields until the user clicks ,,into cart".

The display in orders and cart and so on is controlled in function plgVmOnViewCartVM3. Everything works fine, only the necessary values are displayed.

But in the database in table order_items (field product_attribute) all possible inputs are stored.

Now for some other reasons, i have to check the database values. these should only contain the needed values. so i have to get rid of the unwanted values.

What do you think is the right way to manage that?

I just tried in function plgVmPrepareCartProduct to "unset($selected['someKey']);", without any effect. the value is stored.

Some ideas?

Thanks for your answer!!!

Studio 42

Simply remove the name attributes of unneeded inputs in cart.
eg.
<input class="myclass" name="xxx">
to
<input class="myclass">
If you need to manipulate the datas, simply use the class attribute in your javascript.
For ajax you can easy do the same using jquery to get the values.
If you cannot do it directly. Remove the name attribute on calling form submit.

sprachrohr

this sounds good. i will give it a try.

thanks a lot!

sprachrohr

yes it workes!!! and it is that easy...

the only thing is, it doesnt work on form submit, only on click on addtocart. but thats ok.

thanks a lot!!!