Working with Options

  • Posts: 157
  • Thank you received: 8
  • Hikashop Business
11 years 2 months ago #159823

-- url of the page with the problem -- : www.bestpub.com/books/new-book-titles/pr...of-our-lifetime.html
-- HikaShop version -- : 2.3.1
-- Joomla version -- : 2.5.20
-- PHP version -- : 5.3.27
-- Browser(s) name and version -- : n/a
-- Error-message(debug-mod must be tuned on) -- : n/a

I am working with the Options for products, and want to use it as an upselling feature. This client sell books, and wants to upsell other books that are related to the current book the user is looking at. Essentially I want to use the Options feature to recommend to the user another book at a discount. All they need to do is choose yes and that book is added to the shopping cart, along with the book they are looking at.

I achieved this with some simple edits to the PHP in the Product Option file to inject some text, then the name of the book, and some closing text. This is working well, but I would like to customize it more.

If you look at the above URL, you will see that the text currently reads:

Purchase this book now and add a discounted copy of "Hyperbaric Oxygen for Neurological Disorders!" Click "YES" in the drop down box to the right.

I inserted into the text the name of the book that the option is for. That works well, but I would like the text to read more like:

Purchase "Oxygen and the Brain" now and add a discounted copy of "Hyperbaric Oxygen for Neurological Disorders!" Total for the set is only $65! Click "YES" in the drop down box to the right.

Doing this I need to insert the title of the current book they are looking at, as well as do some calculations for the total price by adding the cost of the book that is the option to the cost of the book they are looking at.

I know this is likely simple to do, but I am uncertain how to call for the name of the book on the page, or get the prices for the two books. Can anyone help me with the code to do both of those? I can likely take it from there.

Please Log in or Create an account to join the conversation.

  • Posts: 84298
  • Thank you received: 13694
  • MODERATOR
11 years 2 months ago #159947

Hi,

Here is below the information you requested.

Price of the main product:

$this->element->prices[0]->price_value

Price of the option product:
$this->element->options[0]->prices[0]->price_value

Name of the main product:
$this->element->product_name

Name of the option product:
$this->element->options[0]->product_name

Please Log in or Create an account to join the conversation.

  • Posts: 157
  • Thank you received: 8
  • Hikashop Business
11 years 2 months ago #159959

That was very helpful!

I got the following to work perfectly:

Price of the main product:

$this->element->prices[0]->price_value

Name of the main product:
$this->element->product_name

The ones you listed for the option didn't work though.

I looked more at the context of the code in the view, and found that the following worked for the option information:

Price of the option product:
$optionInfo->prices[0]->price_value

Name of the option product:
$optionInfo->product_name

I also then put the original price of the upsell book in the Retail Price of the option product, and then was able to call that with:
$optionInfo->product_msrp

Add a little math, and my upsell text now looks great and is flexible enough to work with any products. The upsell text now looks like this:

Purchase "Oxygen and the Brain: The Journey of Our Lifetime" now and add a discounted copy of "Hyperbaric Oxygen for Neurological Disorders." Total for the set is only $65 - A value of $128.49! Click "YES" in the drop down box to the right.


Thank you for the help. This will work great for upselling.

Please Log in or Create an account to join the conversation.

Time to create page: 0.057 seconds
Powered by Kunena Forum