Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

quantity buttons question about exact syntax


Guest

Recommended Posts

I'm have combined two contributions for quantity buttons and text, but this script is limited to 3 options.

 

 

function picto_qty($quantity=0) {

global $warning_stock ;

if ($quantity <=-20) {$picto = tep_image(DIR_WS_ICONS.'puce_rouge.gif', STOCK_LEVERTIJD).'<br>'. TEXT_STOCK_TIME ;

} elseif ($quantity ==0 ){ $picto = tep_image(DIR_WS_ICONS.'puce_rouge.gif', STOCK_LIMITE).'<br>'. TEXT_STOCK_NO_STOCK;

} else { $picto = tep_image(DIR_WS_ICONS.'puce_verte.gif', STOCK_DISPO ).'<br>'. TEXT_STOCK_ON_STOCK;

}

return $picto;

}

 

 

 

 

Wat I want is 5 options instead of 3, example:

 

stock is <= -20 Ask delivery time

stock between <=0 and -19 Out of stock

stock between >=1 and 2 Very few onstock

stock between >=3 and 5 few on stock

stock >=6 On stock

 

 

IS it possible to have a repeated else and how is the exact syntax to the options between. I tryed to separated the operators with a comma:

 

<=0,>=-19

 

But that don't work out

Link to comment
Share on other sites

Try:

 

global $warning_stock; 
if ($quantity <=-20) 
{ $picto = tep_image(DIR_WS_ICONS.'puce_rouge.gif', STOCK_LEVERTIJD).'<br>'. TEXT_STOCK_TIME; 
} 
elseif (($quantity < 1 ) and ($quantity >=-19 ))
{ i $picto = tep_image(DIR_WS_ICONS.'puce_rouge.gif', STOCK_LEVERTIJD} 
elseif (($quantity > 0 ) and ($quantity < 3 ))
{  $picto = tep_image(DIR_WS_ICONS.'puce_rouge.gif', STOCK_LEVERTIJD } 
elseif (($quantity > 2 ) and ($quantity < 6 ))
{  $picto = tep_image(DIR_WS_ICONS.'puce_rouge.gif', STOCK_LEVERTIJD } 
else 
{ $picto = tep_image(DIR_WS_ICONS.'puce_verte.gif', STOCK_DISPO ).'<br>'. TEXT_STOCK_ON_STOCK; } 
return $picto; 
}

 

Don't forget to change the image reference for each one to what you want.

Your online success is Paramount.

Link to comment
Share on other sites

Must I skip the line?

 

function picto_qty($quantity=0) {

 

and is there a typo in line 7?

 

{ i $picto

 

The i ??

Link to comment
Share on other sites

Found some typo's but no problem you point me to the right direction and its working now... THX

 

Shoot be:

 

function picto_qty($quantity=0) {

global $warning_stock ;

if ($quantity <=-20) { $picto = tep_image(DIR_WS_ICONS.'puce_rouge.gif', STOCK_LEVERTIJD).'<br>'. TEXT_STOCK_TIME ;

} elseif (($quantity < 1 ) and ($quantity >=-19 )) { $picto = tep_image(DIR_WS_ICONS.'puce_rouge.gif', STOCK_LIMITE).'<br>'. TEXT_STOCK_NO_STOCK;

}

elseif (($quantity > 0 ) and ($quantity < 3 )) { $picto = tep_image(DIR_WS_ICONS.'puce_rouge.gif', STOCK_LIMITE).'<br>'. STOCK_VERY_FEW_STOCK ;

}

elseif (($quantity > 2 ) and ($quantity < 6 )) { $picto = tep_image(DIR_WS_ICONS.'puce_rouge.gif', STOCK_LIMITE).'<br>'. STOCK_FEW_STOCK ;

}

else { $picto = tep_image(DIR_WS_ICONS.'puce_verte.gif', STOCK_ON_STOCK ).'<br>'. TEXT_STOCK_ON_STOCK ;

}

return $picto;

}

 

 

Just a raw example, because text and images are in this case the same..!! I'm still tunning..

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...