Post by AnonyMoose » Tue Oct 04, 2011 8:05 pm

It half works in 1.5.1.3, in my code I have:

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'],
								'price'                   => (float)$option_value['price'] ? $this->currency->format($this->tax->calculate($option_value['price']+$product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax'))) : false,
								'price_prefix'            => ''
							);
						}
					}
It calculates option final price only for those options with 'Price' set to something. So if I take Product with base price of $5 and options: 1 (no change) and 2 (+3.50) I get:

Product 1 - $5.00

- option 1
- option 2 ($8.50)

What i'd like to have is

Product 1 - $5.00

- option 1 ($5.00)
- option 2 ($8.50)


I can get round this by setting Option 1 price to something small like 0.0001 so it gets rounded to $5.00 anyway, but it's not very elegant solution..

Bigger problem is when I set Special on the product, then I get:

Product 1 - $5.00 (crossed), now $2.99

- option 1 ($5.00)
- option 2 ($8.50)

Any suggestions?

New member

Posts

Joined
Wed Jul 20, 2011 5:35 pm

Post by AnonyMoose » Tue Oct 04, 2011 10:08 pm

Right, got half way there, basically my code looks like this now:

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'],
								'price'                   => (float)$option_value['price'] ? $this->currency->format($this->tax->calculate($option_value['price']+$product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax'))) : false,
								'price_prefix'            => ''
							);
						}
					}

This will create following output:

Product 1 - $5.00
- Option 1 - $5.00
- Option 2 - $8.50

What I want now is to include special in the price displayed, so I've done:

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'],
								'price'                   => if((float)product_info['special']) { $this->currency->format($this->tax->calculate($option_value['price']+$product_info['special'], $product_info['tax_class_id'], $this->config->get('config_tax'))) : false,}
					else { $this->currency->format($this->tax->calculate($option_value['price']+$product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax'))) : false,
					},
								'price_prefix'            => ''
							);
						}
					}

And got Parse error: syntax error, unexpected T_IF in /home/(...)product.php on line 259


Line 259:

Code: Select all

                        'price'                   => if((float)product_info['special']) { $this->currency->format($this->tax->calculate($option_value['price']+$product_info['special'], $product_info['tax_class_id'], $this->config->get('config_tax'))) : false,}


Could someone help?
Last edited by AnonyMoose on Tue Oct 04, 2011 11:17 pm, edited 4 times in total.

New member

Posts

Joined
Wed Jul 20, 2011 5:35 pm

Post by Qphoria » Tue Oct 04, 2011 10:47 pm

emkla wrote: Don't want +/-, because then the customer will have to sit with a calculator to figure out the prize of option size 2 wich is kinda stupid.
Only if he is too stupid to just add it to cart and see the price.

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by AnonyMoose » Tue Oct 04, 2011 11:03 pm

Qphoria wrote:
emkla wrote: Don't want +/-, because then the customer will have to sit with a calculator to figure out the prize of option size 2 wich is kinda stupid.
Only if he is too stupid to just add it to cart and see the price.
Asking customers to add all products they're interested in to cart and then remove them to check prices or calculate prices, taxes etc. in their heads isn't exactly a solution. They will just go shopping somewhere else, where it's more clear..

New member

Posts

Joined
Wed Jul 20, 2011 5:35 pm

Post by ihugmedia » Tue Oct 18, 2011 12:42 pm

Hi,
I'm using OpenCart for a client site - I've found this post incredibly useful. I managed to fix up AnonyMoose's code and wanted to share it back - so here we go!

Code: Select all

foreach ($option['option_value'] as $option_value) {
						if (!$option_value['subtract'] || ($option_value['quantity'] > 0)) {
						
						if((float)$product_info['special']) { 
							$x = $this->currency->format(
								$this->tax->calculate(
									$option_value['price']+$product_info['special'],
									$product_info['tax_class_id'],
									$this->config->get('config_tax')
								)
							);
						} else { 
							$x = $this->currency->format(
								$this->tax->calculate(
									$option_value['price']+$product_info['price'], 
									$product_info['tax_class_id'], 
									$this->config->get('config_tax')
								)
							);
						}
						
						$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'],
							'price'                   => $x,
							'price_prefix'            => ''
						);
						}
					}
Not sure how well it works, but there's no errors so I'm hoping it all goes smoothly, Thanks for the help guys! :)

Newbie

Posts

Joined
Tue Oct 18, 2011 12:37 pm

Post by Qphoria » Tue Oct 18, 2011 9:07 pm

Options Boost has been released and has the option to show the full option price rather than the +2.00

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Web Studio West » Thu Oct 27, 2011 12:15 am

ihugmedia wrote:Hi,
I'm using OpenCart for a client site - I've found this post incredibly useful. I managed to fix up AnonyMoose's code and wanted to share it back - so here we go!

Code: Select all

foreach ($option['option_value'] as $option_value) {
						if (!$option_value['subtract'] || ($option_value['quantity'] > 0)) {
						
						if((float)$product_info['special']) { 
							$x = $this->currency->format(
								$this->tax->calculate(
									$option_value['price']+$product_info['special'],
									$product_info['tax_class_id'],
									$this->config->get('config_tax')
								)
							);
						} else { 
							$x = $this->currency->format(
								$this->tax->calculate(
									$option_value['price']+$product_info['price'], 
									$product_info['tax_class_id'], 
									$this->config->get('config_tax')
								)
							);
						}
						
						$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'],
							'price'                   => $x,
							'price_prefix'            => ''
						);
						}
					}
Not sure how well it works, but there's no errors so I'm hoping it all goes smoothly, Thanks for the help guys! :)
Thanks ihugmedia! This code is incredibly useful! I was able to copy and paste in about a minute. Works like a charm.

Looking at some previous posts, I don't think some people get how to enter prices. The main product price (in the product data tab) would be set to the small size price (i.e. $20.00). Then each attribute is the additional cost. So the first attribute would be "small" and the additional cost would be +$0. Medium +$5. Large +$10. Etc. Therefore, the main product price would show $20 and the sizes would be: Small $20, Medium $25, Large $30.

Hopefully that's not more confusing, but this does work and prices are correct in the shopping cart.

Thanks again!

Web Studio West
Phoenix Website Design


User avatar

Posts

Joined
Fri Sep 09, 2011 12:12 am
Location - Scottsdale AZ USA

Post by Web Studio West » Thu Oct 27, 2011 12:25 am

Qphoria wrote:Options Boost has been released and has the option to show the full option price rather than the +2.00
Excellent! Thank you Qphoria. Your extensions/modules (like offline credit card) are a lifesaver. I've already had two websites require full prices for product options and one more on the way. I will definitely purchase Options Boost for that project.

Thanks again!

Web Studio West
Phoenix Website Design


User avatar

Posts

Joined
Fri Sep 09, 2011 12:12 am
Location - Scottsdale AZ USA

Post by archisesto » Tue Nov 15, 2011 1:17 pm

highvibes wrote:Here's the vQmod ...
options_resulting_price.xml
I installed but doesn't work for me. :(

Newbie

Posts

Joined
Tue Nov 15, 2011 10:29 am

Post by haydent » Tue Jan 17, 2012 1:17 pm

archisesto wrote:
highvibes wrote:Here's the vQmod ...
The attachment options_resulting_price.xml is no longer available
I installed but doesn't work for me. :(

i had same problem so redid it for latest OC 1.5.1.3

though it really only shows correctly with 1 set of options....

Attachments

Last edited by haydent on Thu Jan 26, 2012 7:53 am, edited 2 times in total.

User avatar
New member

Posts

Joined
Wed Nov 09, 2011 9:50 am
Location - Sydney, Australia

Post by yadino » Tue Jan 17, 2012 2:54 pm

thanks guys! it's very useful!
now i want add "=" to adminpanel. it will be +,-,= signs.
i'll post it here when will be done

Newbie

Posts

Joined
Tue Jan 17, 2012 2:50 pm

Post by haydent » Tue Jan 17, 2012 3:25 pm

yadino wrote:thanks guys! it's very useful!
now i want add "=" to adminpanel. it will be +,-,= signs.
i'll post it here when will be done
thats a little more work, and something luckily i can get away with not doing for my client so ill be giving it a miss for now.

User avatar
New member

Posts

Joined
Wed Nov 09, 2011 9:50 am
Location - Sydney, Australia

Post by Michel1985 » Tue Jan 17, 2012 6:45 pm

Hi,

Im relatively new to OpenCart and I have a question: I dont want the option prices to be visible when someone isnt logged in, is that possible?
I changed the settings in the controlpanel and you cant see the normal prices, but you still see the option price of the serie (see:http://krott.nl/webshop/index.php?route ... duct_id=51).

Does someone know how to fix this, so you dont see any of the prices unless you are logged in?

Hope that someone can help!

Cheers,
Michel

Newbie

Posts

Joined
Tue Jan 17, 2012 5:21 pm

Post by MattL » Wed Jan 18, 2012 4:45 am

ihugmedia wrote:Hi,
I'm using OpenCart for a client site - I've found this post incredibly useful. I managed to fix up AnonyMoose's code and wanted to share it back - so here we go!

Code: Select all

foreach ($option['option_value'] as $option_value) {
						if (!$option_value['subtract'] || ($option_value['quantity'] > 0)) {
						
						if((float)$product_info['special']) { 
							$x = $this->currency->format(
								$this->tax->calculate(
									$option_value['price']+$product_info['special'],
									$product_info['tax_class_id'],
									$this->config->get('config_tax')
								)
							);
						} else { 
							$x = $this->currency->format(
								$this->tax->calculate(
									$option_value['price']+$product_info['price'], 
									$product_info['tax_class_id'], 
									$this->config->get('config_tax')
								)
							);
						}
						
						$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'],
							'price'                   => $x,
							'price_prefix'            => ''
						);
						}
					}
Not sure how well it works, but there's no errors so I'm hoping it all goes smoothly, Thanks for the help guys! :)
Hi, I've tried using this code and I'm having an error.

The price on the product page for options shows correct, but once you add the item to your cart it only adds the additional cost of the option, not the option plus the regular price.

For example. Product price is $100,

option #1 $0.00 (which should make the total $100)
option #2 $25.00 (should make the total $125)

what happens when you add the item to cart is that only the option value is added. So if you select option #1 it then shows the price in your shopping cart as $0.00

Does anyone know how to fix this?

OpenCart v1.5.3

Newbie

Posts

Joined
Sat Jan 07, 2012 3:32 am

Post by haydent » Wed Jan 18, 2012 6:10 am

i just tested it and it works for me (the xml i posted a couple of posts back)

User avatar
New member

Posts

Joined
Wed Nov 09, 2011 9:50 am
Location - Sydney, Australia

Post by AnonyMoose » Mon Jan 23, 2012 12:13 am

Hi guys,

Great mod, but only half works for me. It always adds Option price even if I select [-] for option in product details so instead of $8 in case of $10 product - $2 option I get $12 total. Shopping cart shows correct $8 price. Any ideas how to fix it?

New member

Posts

Joined
Wed Jul 20, 2011 5:35 pm

Post by AnonyMoose » Mon Jan 23, 2012 12:27 am

Actually there is another flaw when using Options this way. If you have several sets of options, it will mess things up a bit, for example:

- Product - $10
-- Option 1 as radio - base price
-- Option 2 as radio - $2 more

-- Gift wrap as checkbox - $1 extra


Gift wrap option will show $11 no matter what you select in options 1 and 2..

New member

Posts

Joined
Wed Jul 20, 2011 5:35 pm

Post by haydent » Mon Jan 23, 2012 6:21 am

ill look into it :)

User avatar
New member

Posts

Joined
Wed Nov 09, 2011 9:50 am
Location - Sydney, Australia

Post by haydent » Mon Jan 23, 2012 5:33 pm

ok, ive fixed up the issue with minus option values adding, i admit i didnt read the guys code i put in their nor had i tested all options. but its ok now.

as for the issue with more than one set of options, im not doing anything about that, to make that happen it would take a fair bit more javascript and php editing to make it all change dynamically as you change the options selected, and the shop im working on doesnt need that so ill be leaving it for now... (sorry) maybe get the guy above to add it too his mod 'options boost'

Attachments

Last edited by haydent on Thu Jan 26, 2012 7:53 am, edited 1 time in total.

User avatar
New member

Posts

Joined
Wed Nov 09, 2011 9:50 am
Location - Sydney, Australia

Post by bulldog » Thu Jan 26, 2012 12:44 am

Im having an issue with the code where it displays the price for the radial option as the original price even if its zero...can you add some sort of filter so zero doesnt display a + price?

Newbie

Posts

Joined
Thu Jan 26, 2012 12:42 am
Who is online

Users browsing this forum: No registered users and 64 guests