Page 1 of 1

Vqmod problem

Posted: Wed Aug 14, 2019 1:23 am
by johnp
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. :)

Re: Vqmod problem

Posted: Wed Aug 14, 2019 3:36 am
by kestas
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) { ?>

Re: Vqmod problem

Posted: Wed Aug 14, 2019 3:58 am
by johnp
That's great. I'll take a look. Many thanks. :)

Re: Vqmod problem

Posted: Thu Aug 15, 2019 6:26 am
by johnp
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.

Re: Vqmod problem

Posted: Thu Aug 15, 2019 2:52 pm
by kestas
write me PM, maybe I'll help you.

Re: Vqmod problem

Posted: Fri Aug 16, 2019 2:42 am
by cyclops12

Re: Vqmod problem

Posted: Fri Aug 16, 2019 8:56 pm
by johnp
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. :)

Re: Vqmod problem

Posted: Fri Aug 16, 2019 11:59 pm
by cyclops12
try this mate although this will hide the price onproduct/ category pages, featured etc

Re: Vqmod problem

Posted: Sat Aug 17, 2019 3:06 am
by johnp
Nope. No luck with that either. :(

Re: Vqmod problem

Posted: Sat Aug 17, 2019 3:16 am
by cyclops12
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

Re: Vqmod problem

Posted: Sat Aug 17, 2019 6:14 am
by johnp
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. :)

Re: Vqmod problem

Posted: Sun Aug 18, 2019 12:44 am
by cyclops12
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

Re: Vqmod problem

Posted: Sun Aug 18, 2019 2:45 am
by johnp
No probs. I've learnt more about PHP and vqmods so that's not a bad thing. :)