Post by z4m0lx3 » Thu Dec 08, 2011 9:06 am

Hello,

I want to modify how the product options show up in the product page.
First of all, i want radio buttons, not drop-down menu.

And second, I'd like the option to show the total price when selected, not basic price +/- value

I don't know where to start to make this modifications :((

Thanks.

User avatar
Newbie

Posts

Joined
Thu Dec 08, 2011 8:59 am
Location - Bucuresti

Post by straightlight » Thu Dec 08, 2011 9:53 am

The total price may be a bit of work but as for changing the options from a dropdown menu to radio buttons, you can always customize the look and feel from the templates. ;)

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by hydrowire » Thu Dec 08, 2011 2:40 pm

Hi z4m0lx3,

Welcome to OpenCart.

1. You can change option type under Catalog > Options here:
option_type.jpg

option_type.jpg (35.91 KiB) Viewed 13220 times

2. Open and edit /catalog/controller/product/product.php:
Around line 253-264:
Change from:

Code: Select all

foreach ($option['option_value'] as $option_value) {
	if (!$option_value['subtract'] || ($option_value['quantity'] > 0)) {
		$option_value_data[] = array(
			'product_option_value_id'	=> $option_value['product_option_value_id'],
			'option_value_id' 		=> $option_value['option_value_id'],
			'name'                    		=> $option_value['name'],
			'image'                   		=> $this->model_tool_image->resize($option_value['image'], 50, 50),
			'price'                   		=> (float)$option_value['price'] ? $this->currency->format($this->tax->calculate($option_value['price'], $product_info['tax_class_id'], $this->config->get('config_tax'))) : false,
			'price_prefix'            		=> $option_value['price_prefix']
		);
	}
}
To:

Code: Select all

foreach ($option['option_value'] as $option_value) {
	if (!$option_value['subtract'] || ($option_value['quantity'] > 0)) {
		$option_value_data[] = array(
			'product_option_value_id'	=> $option_value['product_option_value_id'],
			'option_value_id' 		=> $option_value['option_value_id'],
			'name'                    		=> $option_value['name'],
			'image'                   		=> $this->model_tool_image->resize($option_value['image'], 50, 50),
			'price'                   		=> (float)$option_value['price'] ? $this->currency->format($this->tax->calculate($product_info['special'] ? $option_value['price'] + $product_info['special'] : $option_value['price'] + $product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax'))) : false,
			'price_prefix'            		=> ''//$option_value['price_prefix']
		);
	}
}
Notice the 'price' and 'price_prefix'.

Several things to note:
-this is a hard-coded change and all other options will be affected by it.
-this won't be logical if you have more than 1 option for each product because the price only shows price of product + that particular option value, not all selected options for the product.

Hope this will help you get started in your modification.

Developing Quality OpenCart Extensions since 2011.
View my extensions


User avatar
Active Member

Posts

Joined
Wed Jan 26, 2011 5:41 pm


Post by z4m0lx3 » Sat Dec 10, 2011 3:16 am

thanks hydrowire, I've solved the total price issue

problem is I have no Catalog>Option in my admin area, is there somewhere I can modify it in the database, using phpmyAdmin maybe? or in the template?

thanks

User avatar
Newbie

Posts

Joined
Thu Dec 08, 2011 8:59 am
Location - Bucuresti

Post by hydrowire » Sat Dec 10, 2011 3:23 am

Hi z4m0lx3,

Unless you change any code in the admin, or else it comes with default installation, you don't have to modify anything to use that.

If you go here http://www.opencart.com/index.php?route ... onstration and login into admin, you should see the default admin menu, and Catalog > Options will be there.

Developing Quality OpenCart Extensions since 2011.
View my extensions


User avatar
Active Member

Posts

Joined
Wed Jan 26, 2011 5:41 pm


Post by z4m0lx3 » Sat Dec 10, 2011 4:21 am

OK, I've solved the radio button options as well :)

One more last thing please, I want the price to show next to the options even if the Option price is "0" (it doesn't show any price now)

How can I do that?

User avatar
Newbie

Posts

Joined
Thu Dec 08, 2011 8:59 am
Location - Bucuresti

Post by hydrowire » Sun Dec 11, 2011 2:09 am

Hi z4m0lx3,

Try this instead:

edit /catalog/controller/product/product.php:
Around line 253-264:

Code: Select all

foreach ($option['option_value'] as $option_value) {
   if (!$option_value['subtract'] || ($option_value['quantity'] > 0)) {
      $option_value_data[] = array(
         'product_option_value_id'   => $option_value['product_option_value_id'],
         'option_value_id'       => $option_value['option_value_id'],
         'name'                          => $option_value['name'],
         'image'                         => $this->model_tool_image->resize($option_value['image'], 50, 50),
         'price'                         => $this->currency->format($this->tax->calculate($product_info['special'] ? $option_value['price'] + $product_info['special'] : $option_value['price'] + $product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax'))),
         'price_prefix'                  => ''//$option_value['price_prefix']
      );
   }
}

Developing Quality OpenCart Extensions since 2011.
View my extensions


User avatar
Active Member

Posts

Joined
Wed Jan 26, 2011 5:41 pm


Post by z4m0lx3 » Mon Dec 12, 2011 7:42 pm

Uhmm, now it shows me like the attachment.

tester 100ml is the option with price "0" but shows "1" next to it instead of the price

Attachments

Capture003.jpg

Capture003.jpg (11.56 KiB) Viewed 13174 times


User avatar
Newbie

Posts

Joined
Thu Dec 08, 2011 8:59 am
Location - Bucuresti

Post by hydrowire » Tue Dec 13, 2011 1:23 am

Hi z4m0lx3,

I tested the code and it works under default theme. The critical line is line 260:

Code: Select all

'price'                         => $this->currency->format($this->tax->calculate($product_info['special'] ? $option_value['price'] + $product_info['special'] : $option_value['price'] + $product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax'))),
Maybe you need to check your custom theme, or the currency. What currency settings are you using? Let me try with your currency.

Developing Quality OpenCart Extensions since 2011.
View my extensions


User avatar
Active Member

Posts

Joined
Wed Jan 26, 2011 5:41 pm


Post by z4m0lx3 » Tue Dec 13, 2011 7:18 am

I don't know what's wrong with this cPanel, I didn't install it, but I don't see any currency settings

the currency is "lei" as in "romanian leu"

User avatar
Newbie

Posts

Joined
Thu Dec 08, 2011 8:59 am
Location - Bucuresti

Post by hydrowire » Tue Dec 13, 2011 12:23 pm

Hi z4m0lx3,

Nothing to do with your hosting cPanel. I mean are you using any special character in your currency you set under Admin > System > Localisation > Currencies that could possibly upset the html code?

Are you using vqmod? try clearing the cache too. The code that I provided is tested and works.

Developing Quality OpenCart Extensions since 2011.
View my extensions


User avatar
Active Member

Posts

Joined
Wed Jan 26, 2011 5:41 pm


Post by z4m0lx3 » Tue Dec 13, 2011 5:18 pm

i think I accidentally missed a character in the code

it works now...i'm very grateful for your help and patience hydrowire

thank you so much :)

User avatar
Newbie

Posts

Joined
Thu Dec 08, 2011 8:59 am
Location - Bucuresti

Post by z4m0lx3 » Tue Dec 13, 2011 5:19 pm

P.S. how do I mark it SOLVED? :D

User avatar
Newbie

Posts

Joined
Thu Dec 08, 2011 8:59 am
Location - Bucuresti

Post by timedemo » Sat Jan 14, 2012 6:01 pm

Hello and thank you hydrowire for the solution, as i had the same question as the OP.

I would like to know if there is any possibility to show these Product Option prices only to the logged-in users. Using the CP options, the product price is hidden unless someone logs in, but the Product Option prices are still shown next to the radio buttons.

Thanks!

Newbie

Posts

Joined
Sat Jan 14, 2012 5:53 pm

Post by hydrowire » Sat Jan 14, 2012 7:23 pm

Hi timedemo,

Open and edit /catalog/controller/product/product.php, look for the following code around line 260:

Code: Select all

'price'                   => (float)$option_value['price'] ? $this->currency->format($this->tax->calculate($option_value['price'], $product_info['tax_class_id'], $this->config->get('config_tax'))) : false,
Just add ' && $this->data['price']' before '?':

Code: Select all

'price'                   => (float)$option_value['price'] && $this->data['price'] ? $this->currency->format($this->tax->calculate($option_value['price'], $product_info['tax_class_id'], $this->config->get('config_tax'))) : false,
That's all. Let me know if there's any problem with it.

Developing Quality OpenCart Extensions since 2011.
View my extensions


User avatar
Active Member

Posts

Joined
Wed Jan 26, 2011 5:41 pm


Post by timedemo » Sat Jan 14, 2012 8:17 pm

Thank you for your quick answer!

At the moment, the code at line 260 looks exactly like the solution you gave to the OP (Product Options showing total price instead of +/- differences)

Code: Select all

'price'                         => $this->currency->format($this->tax->calculate($product_info['special'] ? $option_value['price'] + $product_info['special'] : $option_value['price'] + $product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax'))),
If i replace this with what you suggested me, then it solves indeed my problem (doesn't show Product Option prices for non-logged in users) but it loses the total price bit (that you solved for the OP). Is there a way to combine the two? :)

Thanks for your time.

Newbie

Posts

Joined
Sat Jan 14, 2012 5:53 pm

Post by hydrowire » Sat Jan 14, 2012 8:32 pm

Hi timedemo,

How about this:

Code: Select all

'price'                         => $this->data['price'] ? $this->currency->format($this->tax->calculate($product_info['special'] ? $option_value['price'] + $product_info['special'] : $option_value['price'] + $product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax'))) : false,
Let me know if any problem with it.

Developing Quality OpenCart Extensions since 2011.
View my extensions


User avatar
Active Member

Posts

Joined
Wed Jan 26, 2011 5:41 pm


Post by timedemo » Sat Jan 14, 2012 8:39 pm

Yay! Works like a charm!

Thank you again.

Newbie

Posts

Joined
Sat Jan 14, 2012 5:53 pm

Post by MM1972 » Tue Oct 22, 2013 3:19 am

Hello,

I pretty new with oc but getting it under control, this topic here was very usefull, i work with mijoshop (opencart) for joomla, my price total in the options is now ok, but when i look in the backend.. all the options are simply put together.. not nicely as it should be. see the attachted file.
Can u or some help me please..
Thanks..

Attachments

'uw domeinnaam' - Administratie 2013-10-21 21-15-23.png

'uw domeinnaam' - Administratie 2013-10-21 21-15-23.png (34.17 KiB) Viewed 10746 times


Newbie

Posts

Joined
Tue Oct 22, 2013 3:10 am

Post by MM1972 » Tue Nov 26, 2013 3:47 am

MM1972 wrote:Hello,

I pretty new with oc but getting it under control, this topic here was very usefull, i work with mijoshop (opencart) for joomla, my price total in the options is now ok, but when i look in the backend.. all the options are simply put together.. not nicely as it should be. see the attachted file.
Can u or some help me please..
Thanks..

Solved

Newbie

Posts

Joined
Tue Oct 22, 2013 3:10 am
Who is online

Users browsing this forum: No registered users and 21 guests