Post by torm1358 » Wed Apr 21, 2021 2:53 am

I am a bit of a newbie.

I sell prescription 3D glasses at www.optics3d.co.uk. Many of our products require the customer to enter a number or options when entering their prescription. At the moment the options are a long list down the right hand side. What I would like to do is have some of them side by side. Something on the lines of http://www.optics3d.co.uk/RxMulti3D%20B ... asses.html.

Previously, when I was using opencart 1.4.9.1, this was achieved by creating product_n.tpl, where n = the product id number. In this file,. the following code was inserted after if ($options) {:

<?php $mwecounter=-3; ?>
<h2><?php echo $text_option; ?></h2>
<br />
<?php foreach ($options as $option) { ?>
<?php $mwecounter++; ?>
<?php if ($mwecounter==0 OR $mwecounter==14){echo'<table width="715"><tr>';} ?>
<?php if ($mwecounter > -1 AND $mwecounter < 4){echo'<td width="178" valign="bottom">';} ?>
<?php if ($mwecounter > 4 AND $mwecounter < 18){echo'<td width="178" valign="bottom">';} ?>
<?php if ($mwecounter > 18 AND $mwecounter < 28){echo'<td width="178" valign="bottom">';} ?>
<?php if ($mwecounter==4){echo'<td width="178"></td></tr><tr><td width="178" valign="bottom">';} ?>
<?php if ($mwecounter==18){echo'<td width="178"></td></tr><tr><td width="178" valign="bottom">';} ?>
<?php // echo $mwecounter; ?>
<?php if ($option['type'] == 'select') { ?>
<div id="option-<?php echo $option['product_option_id']; ?>" class="option">
<?php if ($option['required']) { ?>
<span class="required">*</span>
<?php } ?>
<b><?php echo $option['name']; ?>:</b><br />
<select name="option[<?php echo $option['product_option_id']; ?>]">
<option value=""><?php echo $text_select; ?></option>
<?php foreach ($option['option_value'] as $option_value) { ?>
<option value="<?php echo $option_value['product_option_value_id']; ?>"><?php echo $option_value['name']; ?>
<?php if ($option_value['price']) { ?>
(<?php echo $option_value['price_prefix']; ?><?php echo $option_value['price']; ?>)
<?php } ?>
</option>
<?php } ?>
</select>
</div>
<?php if ($mwecounter > -1 AND $mwecounter < 4){echo'</td>';} ?>
<?php if ($mwecounter > 4 AND $mwecounter < 28){echo'</td>';} ?>
<?php if ($mwecounter==7 OR $mwecounter==21){echo'</tr><tr>';} ?>
<?php if ($mwecounter==11 OR $mwecounter==25){echo'</tr><tr>';} ?>
<?php if ($mwecounter==13 OR $mwecounter==27){echo'</tr></table>';} ?>
<?php } ?>

I would like to do the same sort of thing with my current opencart website by creating product_n.twig files with something like the code above inserted at the appropriate place, which I would imagine would be after line 162 which is '<div id="product"> {% if options %}'. However, I do not know how to tell the website to look to different product template files. How do I use different product template for different products and would the code above still work?

The website is using opencart 3.0.3.6 using the default theme and the only installed extension is cookiesagreement.

I hope someone will be able to help.

Thank you in advance.

Newbie

Posts

Joined
Tue Oct 11, 2016 11:03 pm

Post by grgr » Wed Apr 21, 2021 3:42 pm

This is a simple thing that I used for myself, welcome to it.

add templates to a new folder in ../template/product_id/

name the template files productxxx where xxx is the product_id (eg. product334.twig).

Attachments


-
Image Image Image Image
VIEW ALL EXTENSIONS * EXTENSION SUPPORT * WEBSITE * CUSTOM REQUESTS


User avatar
Active Member

Posts

Joined
Mon Mar 28, 2011 4:08 pm
Location - UK

Post by torm1358 » Wed Apr 28, 2021 1:46 am

Thank you very much for your reply. I would just like to clarify a few things.
I downloaded and installed using the extension installer, product.template.override.ocmod.zip
I created a the new folder: /catalog/view/theme/default/template/product_id
Into this folder I added my modified product template, product294.twig
I have clear the theme and SASS chaches
So far what I have done has had no effect. Have what I have done been correct, or have I made a mistake? Should the new folder been .../template/product294/ or .../template/product_294?
Thank you in advance.
Colin

Newbie

Posts

Joined
Tue Oct 11, 2016 11:03 pm

Post by by mona » Wed Apr 28, 2021 4:34 am

grgr is not around everyday - so just as a thought OC3.0.3.6
- have you refreshed your modifications?
- do you have the OCMOD OC3.0.3.6 fix?
a. If not go into the log tab - RED CLEAR button - then yellow REFRESH button fixes it
b. search the marketplace for OC3.0.3.6 twig fix
c. If you still have a problem report back

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


Spinning Social : Links : Menus : Payments : Socials : Ads : Screen Backgrounds : Galleries : Headers : Banners : Promos


Active Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by torm1358 » Thu Apr 29, 2021 1:59 am

Thank you Mona for your reply. I did not have the OCMOD OC3.0.3.6 fix, so I did the following steps

1. I went to system>Maintenance>Error Logs and I cleared them by hitting the red button.
2. From the OC Marketplace website, I downloaded fix.twig.ocmod.zip (https://www.opencart.com/index.php?rout ... _license=0)
3. I used the installer in Extensions>Installer and I uploaded fix.twig.ocmod.zip, which installed without any error messages.
4. I went to the dashboard and refreshed both the Theme and SASS chaches.
5. I refreshed my modifications at Extensions>Modifications

After doing all of this, I checked product 294, but it is still using the main product template (I added some text at the bottom of the page to identify the template being used). This can be found at https://optics3d.co.uk/Accessories/p3dipolblack.

Did I download the correct fix? What do I need to do next.

Thank you in advance.

Newbie

Posts

Joined
Tue Oct 11, 2016 11:03 pm

Post by by mona » Thu Apr 29, 2021 2:23 am

Such a simple solution thank you

This works with default theme.
All thanks go to grgr

catalog/view/theme/default/template/product_id/product294.twig

2. From the OC Marketplace website, I downloaded fix.twig.ocmod.zip (https://www.opencart.com/index.php?rout ... _license=0) - no idea it is not a link, I find most of the ones my clients use unreliable - I use my way every time even with the fix installed - it is so simple and keeps my logs shorter and updated

1 == 3. I used the installer in Extensions>Installer and I uploaded [anything] fix.twig.ocmod.zip, which installed without any error messages.
2 == 1. I went to system>Maintenance>Error Logs and I cleared them by hitting the red button. CORRECT and THEN
3 == 5. I refreshed my modifications at Extensions>Modifications THE YELLOW ONE refresh
4. I went to the dashboard and refreshed both the Theme and SASS chaches. Not necessary for this, but no harm done to do

I am not sure if you used the right fix etc .. but come back if you are having a problem and if not please edit the title of the post to include [SOLVED]

Attachments


DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


Spinning Social : Links : Menus : Payments : Socials : Ads : Screen Backgrounds : Galleries : Headers : Banners : Promos


Active Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by torm1358 » Fri Apr 30, 2021 1:41 am

I downloaded and installed both product.template.override2.ocmod.zip and modification_fix_ 3.0.3.x.ocmod.zip. I freshed the modifications and now it works fine. Thank you very much for your help, Mona and Grgr, it is most appreciated. :)

Newbie

Posts

Joined
Tue Oct 11, 2016 11:03 pm
Who is online

Users browsing this forum: No registered users and 23 guests