Problem with Stock feed code

Hi,

I’m a total beginner with php, so please bear with me…

I have a stock feed from a supplier working on a zencart website, it works fine when supplying an amount ie: Stock: 23, but when items are due back in stock it supplies an available date ie 27/3/2012.

In this instance all that would appear is Stock: 27 which obviously causes a problem.

The supplier has sent some suggested revised code, but I just end up with a blank product page.

Here is the relevant original code that just works for the stock figure:

[php]$pida=$_GET[‘products_id’];

$checkManId=$db->Execute(“SELECT manufacturers_id, products_model from products where products_id=”.$pida);
$manId=$checkManId->fields[‘manufacturers_id’];
$pModel=$checkManId->fields[‘products_model’];
if($manId == 2){
$Url=‘http://www.hafele.co.uk/hafele35a1/templates/hafele/StockAvailability2.asp?itemcodes=’.$pModel;
$stockLimit=curl_download($Url);
}

<?php if($manId == 2){ if(trim($stockLimit) == "DISC
"){ $display_qty = 'Stock: 0

'; }else{ $display_qty = 'Stock: '.(int)$stockLimit."

"; } }else{ $display_qty = (($flag_show_product_info_in_cart_qty == 1 and $_SESSION['cart']->in_cart($_GET['products_id'])) ? '

' . PRODUCTS_ORDER_QTY_TEXT_IN_CART . $_SESSION['cart']->get_quantity($_GET['products_id']) . '

' : ''); } [/php] The revised code that causes a blank product page is as follows, as far as I can see it just has the one extra }elseif statement: [php]$pida=$_GET['products_id']; $checkManId=$db->Execute("SELECT manufacturers_id, products_model from products where products_id=".$pida); $manId=$checkManId->fields['manufacturers_id']; $pModel=$checkManId->fields['products_model']; if($manId == 2){ $Url='http://www.hafele.co.uk/hafele35a1/templates/hafele/StockAvailability2.asp?itemcodes='.$pModel; $stockLimit=curl_download($Url); } <?php if($manId == 2){ if(trim($stockLimit) == "DISC
"){ $display_qty = 'Stock: 0

'; }elseif (strpos(trim($stockLimit), '/')) { $display_qty = 'Available: '.$stockLimit."

"; }else { $display_qty = 'Stock: '.(int) $stockLimit."

"; } }else{ $display_qty = (($flag_show_product_info_in_cart_qty == 1 and $_SESSION['cart']->in_cart($_GET['products_id'])) ? '

' . PRODUCTS_ORDER_QTY_TEXT_IN_CART . $_SESSION['cart']- >get_quantity($_GET['products_id']) . '

' : ''); } [/php] Any help would be greatly appreciated. Thanks Phil

Clearly I’m not seeing all the code but having a ‘<?php' smack in the middle of php code with no '?>’ concerns me.

A blank page usually indicate a fatal error in your php. check the logs to see which line failed and correct the error. Fixing one error may reveal others.

Hi,

Thanks for your reply, that was just a small section of the code, this is the working version with the ‘?>’

thanks

[php]<?php
if($manId == 2){
if(trim($stockLimit) == “DISC
”){
$display_qty = ‘Stock: 0

’;
}else{
$display_qty = ‘Stock: ‘.(int)$stockLimit."

";
}
}else{
$display_qty = (($flag_show_product_info_in_cart_qty == 1 and $_SESSION[‘cart’]->in_cart($_GET[‘products_id’])) ? ‘

’ . PRODUCTS_ORDER_QTY_TEXT_IN_CART . $_SESSION[‘cart’]->get_quantity($_GET[‘products_id’]) . ‘

’ : ‘’);
}
if ($products_qty_box_status == 0 or $products_quantity_order_max== 1) {
// hide the quantity box and default to 1
$the_button = ‘’ . zen_draw_hidden_field(‘products_id’, (int)$_GET[‘products_id’]) . zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT);
} else {
// show the quantity box
$the_button = ‘’.PRODUCTS_ORDER_QTY_TEXT .’
’ . zen_get_products_quantity_min_units_display((int)$_GET[‘products_id’]) . ‘
’ . zen_draw_hidden_field(‘products_id’, (int)$_GET[‘products_id’]) . zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT);
}
$display_button = zen_get_buy_now_button($_GET[‘products_id’], $the_button);
?>[/php]
Sponsor our Newsletter | Privacy Policy | Terms of Service