Post by LIBERTY_GUY » Wed Jul 17, 2013 1:41 am

Using the options for a product, for a text input by the user such as someone adding customised text for a personalised item.

Let's say the option box is filled by an option value in the admin panel i.e. 'enter name'. If you click the add the add to cart button it will automatically add this default option value in this case accept 'enter name' ? Other carts appear to validate to see if you have added some text other than the default option value.

Is this something that should be rectified within the core code? Alternatively if someone knows which bit of code needs altering, please feel free to share. :)

New member

Posts

Joined
Fri Jun 21, 2013 5:14 pm

Post by Qphoria » Wed Jul 17, 2013 4:45 am

So you want us to code around the stupidity of people? ::) ;D

Code: Select all

 Other carts appear to validate to see if you have added some text other than the default option value.
What other carts? Name 3 that do this!

Yea it can be done pretty easily in the checkout/cart/add function. I'll take a look when I get home.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by LIBERTY_GUY » Wed Jul 17, 2013 5:33 am

Qphoria wrote:So you want us to code around the stupidity of people? ::) ;D

Name 3 that do this!

Yea it can be done pretty easily in the checkout/cart/add function. I'll take a look when I get home.
Thanks Qphoria.. Sadly anyone with an online presence will happily confirm some customers sheer stupidity, when it comes to undertaking a simple transaction. ;D

Q: What size is it? A: it is in the item description in bold red type....
Q: Do you ship to Scotland? A: We state worlwide shipping on every page (sigh).

Anything that factors out any customer indescretion when wildly pushing online buttons without thought, will always be valued by any online enterprise... lol

The carts I have seen that validate user unput either show the option value 'ghosted out' so it is never posted to the cart, or it disappears when the box is selected with the cursor and typing commences. Have recently evaluated over 25 carts in last few weeks, so which cart offered which feature is lost in 'semi comatosed land' now. Other than to say Opencart overall, left the mighty Zen and Prestashop looking like rank amateurs. :laugh:

New member

Posts

Joined
Fri Jun 21, 2013 5:14 pm

Post by Qphoria » Thu Jul 18, 2013 11:01 pm

LIBERTY_GUY wrote: The carts I have seen that validate user unput either show the option value 'ghosted out' so it is never posted to the cart, or it disappears when the box is selected with the cursor and typing commences.
That is something that HTML 5 offers natively so in 2.0 it should be quite easy to do.

But we can do this for now at the validation level.

UPDATE: I've added a vQmod version of this mod as well (attached at bottom)

Only tested on 1.5.5.1

1. EDIT: catalog/controller/checkout/cart.php

2. FIND:

Code: Select all

foreach ($product_options as $product_option) {
	if ($product_option['required'] && empty($option[$product_option['product_option_id']])) {
		$json['error']['option'][$product_option['product_option_id']] = sprintf($this->language->get('error_required'), $product_option['name']);
	}
}
3. REPLACE WITH:

Code: Select all

foreach ($product_options as $product_option) {
	if ($product_option['required'] && empty($option[$product_option['product_option_id']])) {
		$json['error']['option'][$product_option['product_option_id']] = sprintf($this->language->get('error_required'), $product_option['name']);
	}
	if (($product_option['type'] == 'text' || $product_option['type'] == 'textarea') && $option[$product_option['product_option_id']] == $product_option['option_value']) {
		$json['error']['option'][$product_option['product_option_id']] = sprintf($this->language->get('error_required'), $product_option['name']);
	}
}

Attachments

tested on 1.5.5.1 only


Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by LIBERTY_GUY » Fri Jul 19, 2013 9:39 pm

Thanks for that Qphoria. The vQmod file appears to be working well in combination with the options max length file. Still need to do some more thorough testing with it first, but this will hopefully be of great benefit to those selling personalised products.

New member

Posts

Joined
Fri Jun 21, 2013 5:14 pm
Who is online

Users browsing this forum: No registered users and 11 guests