Post by ajc200x » Sat Oct 18, 2014 12:02 am

I have written this VQMOD when the returned data from my stockfeed when it is called it shows the value and the buy button, but when returns other then a value or a date i need the no buy to work, it shows the date correctly but it does not take away the buying button function where am i going wrong help someone please!!

<file name="catalog/controller/product/product.php">
<operation>
<search position="before"><![CDATA[$this->load->model('tool/image');]]></search>
<add><![CDATA[
$ch = curl_init();

$urlStringData = "http://www.******.co.uk/shop/templates/*****/StockAvailability2.asp?itemcodes=".$product_info["model"];
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Set curl to return the data instead of printing it to the browser.
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT,10);

curl_setopt($ch, CURLOPT_URL, $urlStringData );

$hafelestatus = curl_exec($ch);
curl_close($ch);
$pos = strrpos($stockstatus, "/" );

if($pos === false)
{
$this->data['stock'] = $stockstatus ;
}
else
{
$this->data['nobuy'] = "1";

}
]]></add>
</operation>
</file>

Newbie

Posts

Joined
Wed Oct 15, 2014 10:06 pm

Post by tacobandito » Sat Oct 18, 2014 12:25 am

Well, it looks like you've properly setup a $nobuy variable, but just setting that up is not going to prevent the item from being purchased. There's a lot of ways you could do that, but probably the easiest one would be to wrap the add to cart button in an if statement, and not show it if $nobuy = 1; The problem with that though is that you'd need to do it in a lot of areas, so maybe doing some work to the addtocart function to return an error if $nobuy is set to one would be a faster approach.

[module] PayPal Pro w/Recurring Profiles FREE
[module] 1 Click "Amazon Style" Checkout w/PayPal Pro FREE
[module] Adjustable PayPal Pro Fee FREE
[module] Add Sample To Cart LITE FREE
The guide to fixing just about everything wrong with OpenCart FREE!
Add INFINITE SCROLL to your homepage for FREE!
Live update product price for FREE!
Dynamic generation of Opencart coupon, FREE!
Hire me


User avatar
Active Member

Posts

Joined
Sat Mar 30, 2013 12:27 am
Location - Springfield, MA
Who is online

Users browsing this forum: No registered users and 49 guests