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

How to get user value of custom_text_plugin when you have $product

Started by vigier, May 27, 2012, 15:06:14 PM

Previous topic - Next topic

vigier

Hi,

I'm hacking helpers\cart.php to add a check before items are added to the cart for certain values the user filled in two custom_text_plugin fields. At first I uncommented line 375 and lowered it a line to get access to $product -> customfieldsCart. The line is:
$product -> customfieldsCart = empty($tmpProduct -> customfieldsCart)? array(): $tmpProduct -> customfieldsCart;
Don't know why it was commented anyway... (yeah I know that it's not smart to uncomment a line since there is obviously a reason to comment it)

A little later in my code I want to get the user values. I tried the following code
foreach ($product->customfieldsCart as $field) {
$dimensions = $dimensions . ' - ' . $field->comment;
}

It doesn't work. When I change $field->comment to for example $field->custom_value, I do get the contents of custom_value. I can also get values of other attributes, but not the value that the user typed.

Now I have 2 questions:

  • 1. Is it a problem that I uncommented the line?
  • 2. Why won't it get the comment field? Or am I doing something wrong?

Thnx in advance.


PRO

vigier, dont hack the core, modify the plugin to do the check


vigier

But it's impossible to write the check only in the plugin since I have two fields with the product that have a certain relation.
Then I would have to go from the plugin to the product to go to the other plugin... I don't know whether this is even possible...

The maximum dimensions are 1000 on the first dimension, 1600 on the other dimension.
If the user enters 1000 as width and 1600 as height, that's OK
If the user enters 1600 as width and 1000 as height, that's OK
If the user enters 1001 as width and 1001 as height, that's not OK.

Another possibility is to create a new plugin that contain's both fields, but that's out of my league I think.