Post by johnp » Wed Aug 14, 2019 1:23 am

Hi all. Can anyone help please. I'm using the OC Bootstrop Pro theme on a 1.5.6.5 based site running VQMOD 2.6.1. I'm trying to write a Vqmod that removes the price on the product page if the item is set to zero price. I'm almost there but can't get it to work. Can any of the clever ones of you point out my error please.

Here's the block of code on the product page I need to hide if the price is zero.

Code: Select all

<?php if ($price) { ?>
                        <div class="price" itemprop="offers" itemscope itemtype="http://schema.org/Offer">
                            <?php echo $text_price; ?>
                            <?php if (!$special) { ?>
                                <span itemprop="price"><?php echo $price; ?></span>
                            <?php } else { ?>
                                <span class="price-old"><?php echo $price; ?></span> <span class="price-new" itemprop="price"><?php echo $special; ?></span>
                            <?php } ?>
                            <br />
                            <?php if ($tax) { ?>
                                <span class="price-tax"><?php echo $text_tax; ?> <?php echo $tax; ?></span><br />
                            <?php } ?>
                            <?php if ($points) { ?>
                                <span class="reward"><small><?php echo $text_points; ?> <?php echo $points; ?></small></span> <br />
                            <?php } ?>
                            <?php if ($discounts) { ?>
                                <br />
                                <div class="discount">
                                    <?php foreach ($discounts as $discount) { ?>
                                        <?php echo sprintf($text_discount, $discount['quantity'], $discount['price']); ?><br />
                                    <?php } ?>
                                </div>
                            <?php } ?>
                        </div>
                    <?php } ?>
This is my Vqmod code:

Code: Select all

<file name="catalog/view/theme/oc-bootstrap-pro/template/product/product.tpl">
	<operation error="skip">
		<search position="replace"><![CDATA[
	    <?php if ($price) { ?>
		]]></search>
		<add><![CDATA[
		<?php if ($price) != $this->currency->format(0)) { ?>
		]]></add>
	</operation>
    <operation error="skip">
		<search position="replace"><![CDATA[
		<div class="price" itemprop="offers" itemscope itemtype="http://schema.org/Offer">
        ]]></search>
		<add><![CDATA[
       	<?php if ($price) != $this->currency->format(0)) { ?>
		<div class="price" itemprop="offers" itemscope itemtype="http://schema.org/Offer">
        <?php } ?>
		]]></add>
	</operation>
    <operation error="skip">
		<search position="replace"><![CDATA[
		<?php if ($price) != $this->currency->format(0)) { ?>
		<div class="price" itemprop="offers" itemscope itemtype="http://schema.org/Offer">
        <?php ?>
        ]]></search>
		<add><![CDATA[
       	<div class="price" style="display:none;" itemprop="offers" itemscope itemtype="http://schema.org/Offer">
		]]></add>
	</operation>
    </file>
I think it might have something to do with this bit:

Code: Select all

<?php if ($price) { ?>
It's driving me nuts and hopefully one of you can see my mistake. Thank you in advance. :)

Opencart 1.5.6.5/OC Bootstrap Pro/VQMOD 2.6.1 lover, user and geek.
Fast Service for Opencart Installs, Fixing, Development and Upgrades
Plus Ecommerce, Marketing, Mailing List Management and More
https://www.asandwhenbusinessservices.co.uk


User avatar
Active Member

Posts

Joined
Fri Mar 25, 2011 10:25 am
Location - Surrey, UK

Post by kestas » Wed Aug 14, 2019 3:36 am

seems your problem just you need price without currency symbol. So you should declare it for example like this in your catalog/controller/product/product.php file somewhere about line 320 like this:

Code: Select all

$this->data['price_c'] = $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')), '', '', false);
Than in corresponding tpl use:

Code: Select all

<?php if ($price_c) != 0) { ?>

Custom OpenCart modules and solutions. You can write PM with additional questions... Extensions you can find here


Active Member

Posts

Joined
Tue Oct 12, 2010 2:23 am

Post by johnp » Wed Aug 14, 2019 3:58 am

That's great. I'll take a look. Many thanks. :)

Opencart 1.5.6.5/OC Bootstrap Pro/VQMOD 2.6.1 lover, user and geek.
Fast Service for Opencart Installs, Fixing, Development and Upgrades
Plus Ecommerce, Marketing, Mailing List Management and More
https://www.asandwhenbusinessservices.co.uk


User avatar
Active Member

Posts

Joined
Fri Mar 25, 2011 10:25 am
Location - Surrey, UK

Post by johnp » Thu Aug 15, 2019 6:26 am

I couldn't get that to work. I'm trying another way with a vqmod. I need this block to be hidden if the price is 0.00:

Code: Select all

<div class="cart">
                    <div>
                        <?php echo $text_qty; ?>
                        <input type="text" name="quantity" size="2" value="<?php echo $minimum; ?>" />
                        <input type="hidden" name="product_id" size="2" value="<?php echo $product_id; ?>" />
                        <a id="button-cart" class="btn btn-info"><?php echo $button_cart; ?></a>
                        <div class="btn-group">
                            <a class="btn btn-default tooltip-item" data-toggle="tooltip" title="Add to Wishlist" onclick="addToWishList('<?php echo $product_id; ?>');"><span class="glyphicon glyphicon-heart"></span></a> 
                            <a class="btn btn-default tooltip-item" data-toggle="tooltip" title="Add to Compare" onclick="addToCompare('<?php echo $product_id; ?>');"><span class="glyphicon glyphicon-refresh"></span></a>
                        </div>
                    </div>
                    <?php if ($minimum > 1) { ?>
                        <div class="minimum"><?php echo $text_minimum; ?></div>
                    <?php } ?>
                </div>
I'm trying this vqmod but it's not having any of it. I've just added <?php if ($price) : //Product Price ?> in the hope it may work.

Code: Select all

<div class="cart">
                    <div>
                        <?php if ($price) : //Product Price ?>
                        <?php echo $text_qty; ?>
                        <input type="text" name="quantity" size="2" value="<?php echo $minimum; ?>" />
                        <input type="hidden" name="product_id" size="2" value="<?php echo $product_id; ?>" />
                        <a id="button-cart" class="btn btn-info"><?php echo $button_cart; ?></a>
                        <div class="btn-group">
                            <a class="btn btn-default tooltip-item" data-toggle="tooltip" title="Add to Wishlist" onclick="addToWishList('<?php echo $product_id; ?>');"><span class="glyphicon glyphicon-heart"></span></a> 
                            <a class="btn btn-default tooltip-item" data-toggle="tooltip" title="Add to Compare" onclick="addToCompare('<?php echo $product_id; ?>');"><span class="glyphicon glyphicon-refresh"></span></a>
                        </div>
                    </div>
                    <?php if ($minimum > 1) { ?>
                        <div class="minimum"><?php echo $text_minimum; ?></div>
                    <?php } ?>
                </div>
I'm running out of ideas and coffee. If anyone can fix it I'll be very grateful.

Opencart 1.5.6.5/OC Bootstrap Pro/VQMOD 2.6.1 lover, user and geek.
Fast Service for Opencart Installs, Fixing, Development and Upgrades
Plus Ecommerce, Marketing, Mailing List Management and More
https://www.asandwhenbusinessservices.co.uk


User avatar
Active Member

Posts

Joined
Fri Mar 25, 2011 10:25 am
Location - Surrey, UK

Post by kestas » Thu Aug 15, 2019 2:52 pm

write me PM, maybe I'll help you.

Custom OpenCart modules and solutions. You can write PM with additional questions... Extensions you can find here


Active Member

Posts

Joined
Tue Oct 12, 2010 2:23 am

Post by cyclops12 » Fri Aug 16, 2019 2:42 am


Expert Member

Posts

Joined
Sun Sep 27, 2015 1:10 am

Post by johnp » Fri Aug 16, 2019 8:56 pm

I have and several variations but no joy. I think I have found a solution by modyfing a stock control extension. I'll report back if I'm successful. :)

Opencart 1.5.6.5/OC Bootstrap Pro/VQMOD 2.6.1 lover, user and geek.
Fast Service for Opencart Installs, Fixing, Development and Upgrades
Plus Ecommerce, Marketing, Mailing List Management and More
https://www.asandwhenbusinessservices.co.uk


User avatar
Active Member

Posts

Joined
Fri Mar 25, 2011 10:25 am
Location - Surrey, UK

Post by cyclops12 » Fri Aug 16, 2019 11:59 pm

try this mate although this will hide the price onproduct/ category pages, featured etc

Expert Member

Posts

Joined
Sun Sep 27, 2015 1:10 am

Post by johnp » Sat Aug 17, 2019 3:06 am

Nope. No luck with that either. :(

Opencart 1.5.6.5/OC Bootstrap Pro/VQMOD 2.6.1 lover, user and geek.
Fast Service for Opencart Installs, Fixing, Development and Upgrades
Plus Ecommerce, Marketing, Mailing List Management and More
https://www.asandwhenbusinessservices.co.uk


User avatar
Active Member

Posts

Joined
Fri Mar 25, 2011 10:25 am
Location - Surrey, UK

Post by cyclops12 » Sat Aug 17, 2019 3:16 am

Did you use the vqmod or just the edit to the file?
As i made the edit to the currency.php file on a 1.5.6.1 version and zero price was hidden
I take it you know the posted vqmod wont work for earlier versions as paths are different

Expert Member

Posts

Joined
Sun Sep 27, 2015 1:10 am

Post by johnp » Sat Aug 17, 2019 6:14 am

I used the vqmod as you sent it. After a long evening I've managed to cobble together a vqmod myself that's done the trick. :)

Opencart 1.5.6.5/OC Bootstrap Pro/VQMOD 2.6.1 lover, user and geek.
Fast Service for Opencart Installs, Fixing, Development and Upgrades
Plus Ecommerce, Marketing, Mailing List Management and More
https://www.asandwhenbusinessservices.co.uk


User avatar
Active Member

Posts

Joined
Fri Mar 25, 2011 10:25 am
Location - Surrey, UK

Post by cyclops12 » Sun Aug 18, 2019 12:44 am

Yeah sorry about that, I should have mentioned the path difference or at least changed the vqmod to suit 1.5 version.
At least you have it sorted now

Expert Member

Posts

Joined
Sun Sep 27, 2015 1:10 am

Post by johnp » Sun Aug 18, 2019 2:45 am

No probs. I've learnt more about PHP and vqmods so that's not a bad thing. :)

Opencart 1.5.6.5/OC Bootstrap Pro/VQMOD 2.6.1 lover, user and geek.
Fast Service for Opencart Installs, Fixing, Development and Upgrades
Plus Ecommerce, Marketing, Mailing List Management and More
https://www.asandwhenbusinessservices.co.uk


User avatar
Active Member

Posts

Joined
Fri Mar 25, 2011 10:25 am
Location - Surrey, UK
Who is online

Users browsing this forum: No registered users and 8 guests