Post by lelek » Sun Sep 13, 2015 4:35 pm

Hello,

I use opencart version 1.5.3.1

I tried to change the add to cart button on the product page with out of stock message but without any result.

On the product page (/public_html/catalog/view/theme/mytheme/template/product/product.tpl) I replace the following line:

Code: Select all

<div class="cart"><a onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button addToCart"><span><?php echo $button_cart; ?></span></a></div>
with the following codes:

Code: Select all

<?php if ($stock == "In Stock")
     {
          ?> 
<div class="cart"><a onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button addToCart"><span><?php echo $button_cart; ?></span></a></div>
 <?php }
               else
                  {
           ?>
              <a class="button" style="font-size:16px;">Out of Stock</a>
         <?php
                  }
          ?>
Can somebody help me to write correct the code ?

New member

Posts

Joined
Fri Jun 06, 2014 3:08 pm

Post by artcore » Sun Sep 13, 2015 5:41 pm

Looks correct.
Are you using the English language in your frontend?
What does

Code: Select all

<?php var_dump($stock); ?>
output on your product page? (Add the code snippet to your product.tpl first)

Attn: I no longer provide OpenCart extensions, nor future support - this includes forum posts.
Reason: OpenCart version 3+ ;D

Thanks!


User avatar
Active Member

Posts

Joined
Tue Jul 09, 2013 4:13 am
Location - The Netherlands

Post by lelek » Sun Sep 13, 2015 7:37 pm

Hello,

I tried your solution but unfortunately it works not.

New member

Posts

Joined
Fri Jun 06, 2014 3:08 pm

Post by artcore » Sun Sep 13, 2015 7:46 pm

I did not give a solution yet, just tying to get more info...
What is your shop language and what does the code snippet var_dump($stock); output?

paste <?php var_dump($stock); ?> into your product.tpl
open a product page and look for the debugging output on top of your page.

You are searching for "In Stock", if your language is Spanish it would be a different string, maybe "El Stock" ;)

Attn: I no longer provide OpenCart extensions, nor future support - this includes forum posts.
Reason: OpenCart version 3+ ;D

Thanks!


User avatar
Active Member

Posts

Joined
Tue Jul 09, 2013 4:13 am
Location - The Netherlands

Post by lelek » Sun Sep 13, 2015 8:17 pm

Hello,

Sorry, I understand now.

My store frontend language is english.

I have not received debugging output on top of your page.

New member

Posts

Joined
Fri Jun 06, 2014 3:08 pm

Post by artcore » Sun Sep 13, 2015 9:36 pm

No problem!
Are you changing the correct product.tpl?
I see you are using a custom theme 'mytheme'

Attn: I no longer provide OpenCart extensions, nor future support - this includes forum posts.
Reason: OpenCart version 3+ ;D

Thanks!


User avatar
Active Member

Posts

Joined
Tue Jul 09, 2013 4:13 am
Location - The Netherlands

Post by lelek » Sun Sep 13, 2015 9:58 pm

Yes I work on the corect theme, it is 100%.

New member

Posts

Joined
Fri Jun 06, 2014 3:08 pm

Post by artcore » Sun Sep 13, 2015 10:57 pm

In that case, if you want, PM me so I can take a look at your file and solve it for you...

Attn: I no longer provide OpenCart extensions, nor future support - this includes forum posts.
Reason: OpenCart version 3+ ;D

Thanks!


User avatar
Active Member

Posts

Joined
Tue Jul 09, 2013 4:13 am
Location - The Netherlands

Post by lelek » Sun Sep 13, 2015 11:15 pm

Hello,

I sent you a PM

New member

Posts

Joined
Fri Jun 06, 2014 3:08 pm
Who is online

Users browsing this forum: No registered users and 8 guests