Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Changing Out of Stock to Pre Order in New Products


seanwcole

Recommended Posts

Posted

When I am creating new products I want to be able to show items in stock and items that are preorder only. In creating a new product I want to be able to have the option to show the product as a pre order and also be able to put in a date as the last day to order before the product is no longer available. Im not sure if this makes any sense or not but I figured I would at least try.

 

Thanks

Sean

Posted

You could use the way how specials are intregrated into the system.

With some tweaks you could let it function like that.

Another way is to tweak the 'product available date' , when create a new product.

For each you have to edit a few files.

The second option would be the easy way.

When do a call for any product data, it should have an extra field within the 'table products' or as you want 'table_products_description' like field : preorder 1 or 0 (true/false) , maby you could also set an aditional date field.

Posted

I do this for calling the stock status for microformat markup

 

if the stock is 0, then out of stock

if the stock is set and a date available is set and its in the future, then preorder

if just stock set with no other variables, then in stock

 

This is the snippet, I use, place it where all the other logic is going on in top of the file. I dont remember if you need to modify the main query to pull the data available or not.

 

// MF: item offer is in stock?
 $availableDate = tep_date_short($product_info['products_date_available']);
 $newDate = tep_date_short($product_info['products_date_added']);
 $curDate = tep_date_short(date('Y-m-d'));
 //who loves date math? I do! I do!   
 $newDays = (strtotime($curDate) - strtotime($newDate))/86400;
 $updateDays = (strtotime($curDate) - strtotime($upDate))/86400;

 if (strtotime($availableDate) > strtotime($curDate))
   $preOrder = 'True';

 if ($product_info['products_quantity'] == 0) {
  $avialLink = 'OutOfStock';
  $avialText = 'Out Of Stock';
 } elseif ( ($product_info['products_quantity'] > 0) && ($preOrder == 'True') ) {
  $avialLink = 'PreOrder';
  $avialText = 'Pre Order Now';
 } elseif ($product_info['products_quantity'] > 0) {
  $avialLink = 'InStock';
  $avialText = 'In Stock';
 }
// OutOfStock | PreOrder
$prod_price_listing .= '<link itemprop="availability" href="http://schema.org/' . $avialLink . '" />' . PHP_EOL;
$prod_price_listing .= '<span class="stock-text">' . $avialText . '</span>' . PHP_EOL;

 

Then place where you want it to display:

<?php echo $prod_price_listing; ?>

Follow the community build:

BS3 to osCommerce Responsive from the Get Go!

Check out the new construction:

Admin Gone to Total BS!

Posted

I really appreciate the help but when you say "Then place where you want to display: <?php echo $prod_price_listing; ?>"

 

I have no idea where that is and I can not find it anywhere.

 

Thanks again.

Posted

This is also done similarly in the twitter card module:

https://github.com/gburton/osCommerce-2334-bootstrap/blob/master/includes/modules/header_tags/ht_twitter_product_card.php

 

if ( $product_info['products_date_available'] > date('Y-m-d H:i:s') ) {
           $data['data2'] = MODULE_HEADER_TAGS_TWITTER_PRODUCT_CARD_TEXT_PRE_ORDER;
           $data['label2'] = tep_date_short($product_info['products_date_available']);
         } elseif ( $product_info['products_quantity'] > 0 ) {
           $data['data2'] = MODULE_HEADER_TAGS_TWITTER_PRODUCT_CARD_TEXT_IN_STOCK;
           $data['label2'] = MODULE_HEADER_TAGS_TWITTER_PRODUCT_CARD_TEXT_BUY_NOW;
         } else {
           $data['data2'] = MODULE_HEADER_TAGS_TWITTER_PRODUCT_CARD_TEXT_OUT_OF_STOCK;
           $data['label2'] = MODULE_HEADER_TAGS_TWITTER_PRODUCT_CARD_TEXT_CONTACT_US;
         }

Archived

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

×
×
  • Create New...