Jump to content

Out of stock Urgent


Uzair007

Recommended Posts

Welcome Uzair007! Glad to see you made it to the forum.

 

Is this message to be shown on a "per-product" basis? That is, only "Widget", currently out of stock, can be delivered in 8 weeks. The out of stock product, "Wabbit", however, cannot.

 

If this message can be applied globally, then there are at least two edits: the skin template file content.product.php and the class file catalogue.class.php.

 

In content.product.php, find where you want the message to appear, and add:

{if $CTRL_OUT_OF_STOCK}Put your message here.{/if}

In catalogue.class.php, near line 220, starts the logic to set the 'out' flag that indicates whether a product is out of stock.

 

The 'out' flag is initially set to false. Then, a test is made to determine if this product must be handled according to its stock level -- 'use_stock_level'. For this to work, you must enable Use Stock Level in the product's Edit screen.

 

If we are using stock levels to allow/disallow purchasing, there follows a pair of nested tests -- is the stock level zero, then if so, is an out of stock item allowed to be purchased. If not, set 'out' to true and 'allow_purchase' to false.

 

We need to set 'out' to true regardless of whether to allow an out of stock item to be purchased.

 

Near lines 221-228, find:

if ((int)$stock_level <= 0) {
  // Out of Stock
  if (!$GLOBALS['config']->get('config', 'basket_out_of_stock_purchase')) {
    // Not Allowed
    $allow_purchase = false;
    $out = true;
  }
}

Change to:

if ((int)$stock_level <= 0) {
  // Out of Stock
  $out = true;
  if (!$GLOBALS['config']->get('config', 'basket_out_of_stock_purchase')) {
    // Not Allowed
    $allow_purchase = false;
  }
}

For completeness, also near lines 889-896, find:

if ((int)$stock_level <= 0) {
  // Out of Stock
  if (!$GLOBALS['config']->get('config', 'basket_out_of_stock_purchase')) {
    // Not Allowed
    $product['ctrl_purchase'] = false;
    $product['out'] = true;
  }
}
Change to:
if ((int)$stock_level <= 0) {
  // Out of Stock
  $product['out'] = true;
  if (!$GLOBALS['config']->get('config', 'basket_out_of_stock_purchase')) {
    // Not Allowed
    $product['ctrl_purchase'] = false;
  }
}
 
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...