Post by FeedArmy » Mon Jul 20, 2015 10:06 am

Hi all, I have been looking around for a while but can't seem to find a plugin to do what I want.

What I want is that each option available to the parent product can have a unique query string that defines and preselects the options.

So for example
http://example.com/index.php?route=prod ... duct_id=42

There is an option for color
I would like the following url preselect the option
http://example.com/index.php?route=prod ... &color=red[/b]

Is there something available out there?

Kind regards, Emmanuel.

Newbie

Posts

Joined
Mon Jul 20, 2015 10:02 am

Post by inactiveaccount9912 » Mon Jul 20, 2015 11:55 am

I havent seen a plugin for that but you could do it via javascript so that it selects the option based on the url parameters, but they should hold the product option value id instead of name.
ex: index.php?route=product/product&product_id=25&option=251

Code: Select all

<?php if (isset($this->request->get['option'])) { ?>
   <script type="text/javascript">
      $(document).ready(function () {
        $('[value="<?php echo $this->request->get['option'];  ?>"]').attr('selected', 'selected');
      });
   </script>
<?php } ?>
This would be for selects, can be done for other types of options.

Expert Member

Posts

Joined
Fri May 14, 2010 2:36 am

Post by FeedArmy » Tue Jul 21, 2015 1:53 pm

Hi Florinsith,

That does indeed solve the rendering part, and i can figure out how to dynamically create query strings.

However it is intended for Google Shopping which requires if the price changes that the price matches that of the sourcecode.

I guess this is something that can be built in the product landing page theme, instead of using a plugin.

Your info has been helpful. Thank you very much.

Newbie

Posts

Joined
Mon Jul 20, 2015 10:02 am

Post by OCext » Thu Oct 19, 2017 4:30 am

Locate the file: STORE_ROOT/catalog/controller/product/product.php
In it the line: $this->load->view('product/product', $data));
Paste before the following code:

Code: Select all

if(isset($data['options']) && $data['options']){

                foreach ($data['options'] as $available_options) {

                    foreach ($available_options['product_option_value'] as $available_product_option_value) {

                        if($this->request->get['product_option_value_id']==$available_product_option_value['product_option_value_id']){

                            $option_select_type = $available_options['type'];
                            
                            $option_select_povi = $available_options['product_option_value_id'];
                            
                            $option_select_poi = $available_options['product_option_id'];                                 

                            $option_select = '<script type="text/javascript">'.PHP_EOL.PHP_EOL;

                            $option_select .= ' jQuery(function( $ ) { '.PHP_EOL.PHP_EOL;

                            if($option_select_type=='checkbox' || $option_select_type=='image'){

                                $option_select .= "$(\"input[value='".$option_select_povi."']\").click();".PHP_EOL.PHP_EOL;

                            }elseif($option_select_type=='radio'){

                                $option_select.= "$(\"input[value='".$option_select_povi."']\").click();".PHP_EOL.PHP_EOL;

                            }elseif($option_select_type=='select'){

                                $option_select .= "$(\"#input-option".$option_select_poi."\").val(".$option_select_povi.");".PHP_EOL.PHP_EOL;

                                $option_select .= "$(\"#input-option".$option_select_poi."\").change();".PHP_EOL.PHP_EOL;

                            }

                            $option_select .= ' }); '.PHP_EOL.PHP_EOL;

                            $option_select .= '</script> '.PHP_EOL.PHP_EOL;

                            $data['header'] .= $option_select;

                        }

                    }

                }

            }

Newbie

Posts

Joined
Thu Oct 19, 2017 3:52 am

Post by IP_CAM » Fri Oct 20, 2017 7:54 am

$this->load->view('product/product', $data));

Well, this is sure no default OC v.1.5.6.x Code, and that double ))
would probably not work this way in any other default OC version either ... ???

Ernie

My Github OC Site: https://github.com/IP-CAM
5'200 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland
Who is online

Users browsing this forum: No registered users and 111 guests