Jump to content

Out of stock purchases


salvador21

Recommended Posts

I want to allow out of stock purchases, so have enabled it.

However if I do that, then the product page does not show that it is out of stock (as it did with Cubecart4) and customers expect immediate delivery as they can't see it's out of stock.

My store policy and product descriptions state that shipping for out of stock items may take 2 - 3 weeks.

If I disable out of stock purchases customers obviously don't get an add to cart button

Is there a way round this please or am I missing something?

Link to comment
Share on other sites

We need to edit the skin file that shows the product. In the skin template content.product.php, we are given four logical flags: CTRL_ALLOW_PURCHASE (A), CATALOGUE_MODE ©, CTRL_HIDE_PRICES (P), and CTRL_OUT_OF_STOCK (S). We need to figure out what we want and when.

Currently, for displaying the Buy Button, the code will show one of four things: S or P (or possibly nothing at all), or A or C (C is nothing at all).

You want A because you allow out-of-stock purchases, but you also want S to inform the customer of the stock situation.

So (for CC514, but CC515 should be the same),

{if A && !C} Buy {if S} 2-3 Week Delay {/if}

{else}{if P}Login{/if}

{/if}

Make these statements:


      {if ($CTRL_ALLOW_PURCHASE) && (!$CATALOGUE_MODE)}

      <p class="buy_button">

        <input type="text" name="quantity" value="1" class="quantity required" />

        <input type="hidden" name="add" value="{$PRODUCT.product_id}" />

        <input type="submit" value="{$LANG.catalogue.add_to_basket}" class="button_white" />

      </p>

      {else}

          {if $CTRL_HIDE_PRICES}

              <p class="buy_button"><strong>{$LANG.catalogue.login_to_view}</strong></p>

          {else if $CTRL_OUT_OF_STOCK}

              <p class="buy_button"><strong>{$LANG.catalogue.out_of_stock}</strong></p>

          {/if}

      {/if}

      {if $SHARE}





look like:



      {if ($CTRL_ALLOW_PURCHASE) && (!$CATALOGUE_MODE)}

      <p class="buy_button">

        <input type="text" name="quantity" value="1" class="quantity required" />

        <input type="hidden" name="add" value="{$PRODUCT.product_id}" />

        <input type="submit" value="{$LANG.catalogue.add_to_basket}" class="button_white" /><br />

      {if $CTRL_OUT_OF_STOCK}

      <strong>{$LANG.catalogue.out_of_stock} There will be a 2-3 week delay.</strong>

      {/if}

      </p>

      {else}

          {if $CTRL_HIDE_PRICES}

              <p class="buy_button"><strong>{$LANG.catalogue.login_to_view}</strong></p>

          {/if}

      {/if}

      {if $SHARE}





But wait, there's more.



Because of a flawed logical assumption, the S flag does not get set to true if the store has enabled out of stock purchases. So, in the file /classes/catalogue.class.php at around line 227, 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;

                        }

                    }





and change to:



               	 if ((int)$stock_level <= 0) {

                   	 $out = true; // Out of Stock

                        if (!$GLOBALS['config']->get('config', 'basket_out_of_stock_purchase')) {

                            // Not Allowed

                            $allow_purchase = false;

                   	 }

                    }

Link to comment
Share on other sites

In the file skinsYOUR_SKINtemplatescontent.category.php, find:


    {if $product.ctrl_purchase && !$CATALOGUE_MODE}

      <p class="buy_button"><input type="text" name="add[{$product.product_id}][quantity]" value="1" class="quantity" /> <input type="submit" value="{$LANG.catalogue.add_to_basket}" class="button_white" /></p>

    {elseif $product.out}

      <p class="buy_button">{$LANG.catalogue.out_of_stock_short}</p>

    {/if}





And make it look like this:



    {if $product.ctrl_purchase && !$CATALOGUE_MODE}

      <p class="buy_button"><input type="text" name="add[{$product.product_id}][quantity]" value="1" class="quantity" /> <input type="submit" value="{$LANG.catalogue.add_to_basket}" class="button_white" />

    {if $product.out}<br />{$LANG.catalogue.out_of_stock_short}{/if}</p>

    {/if}

Then, again in catalogue.class.php, near line 825, follow the instructions I gave regarding line 227.

Link to comment
Share on other sites

Looking at the HTML source as seen by my browser, I see that the </p> tag is on a line of its own, following the line breaks of the edited content.category.php file.

The {if $product.out} is still false, so that means the second edit for class.category.php is bad or not done.

The code near line 825 was originally:


           	 // Out of Stock

                if (!$GLOBALS['config']->get('config', 'basket_out_of_stock_purchase')) {

                    // Not Allowed

                    $product['ctrl_purchase'] = false;

                    $product['out'] = true;





And needs to be:



           	 $product['out'] = true; // Out of Stock

                if (!$GLOBALS['config']->get('config', 'basket_out_of_stock_purchase')) {

                    // Not Allowed

                    $product['ctrl_purchase'] = false;

Earlier when I said, "follow the instructions I gave regarding line 227," I hope you just didn't blindly copy/paste the exact same code from the line 227 area to the line 825 area, but rather saw the essential difference and extrapolated what was actually to be done.

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...