salvador21 Posted December 7, 2012 Share Posted December 7, 2012 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? Quote Link to comment Share on other sites More sharing options...
bsmither Posted December 8, 2012 Share Posted December 8, 2012 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; } } Quote Link to comment Share on other sites More sharing options...
salvador21 Posted December 8, 2012 Author Share Posted December 8, 2012 Thanks, that's very helpful. It might too complex for me but I'll have a go. It would be nice if this was just possible in the store settings (I think it was in cubecart 4 if I'm not mistaken) Quote Link to comment Share on other sites More sharing options...
salvador21 Posted December 8, 2012 Author Share Posted December 8, 2012 Thanks, that's very helpful. It might too complex for me but I'll have a go. OK I tried it and it seems to work, but changed the font size in the Admin CP, made all the text larger so this is a bit worrying. Any idea why that would happen? Quote Link to comment Share on other sites More sharing options...
bsmither Posted December 8, 2012 Share Posted December 8, 2012 There shouldn't be any connection at all between these storefront edits and anything to do or display in the admin backend. I have no answer without being able to see for myself. Quote Link to comment Share on other sites More sharing options...
salvador21 Posted December 8, 2012 Author Share Posted December 8, 2012 Aha Line 227 in /classes/catalogue.class.php is a bit different: 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; } } Quote Link to comment Share on other sites More sharing options...
salvador21 Posted December 8, 2012 Author Share Posted December 8, 2012 No, that wasn't it that was the same But I think I found the problem. I'd copied and pasted from my email notification. However when I copy and paste from your post above it now appears to be working. The email notifications had somehow taken out some of the code. Quote Link to comment Share on other sites More sharing options...
salvador21 Posted December 9, 2012 Author Share Posted December 9, 2012 Thanks bsmither, however there's still an bit of an issue: Although it works once a cutomer is on the product page, if they add to basket from the category list then they get no out of stock warning. Is that a simple fix I wonder? Thanks. Quote Link to comment Share on other sites More sharing options...
bsmither Posted December 9, 2012 Share Posted December 9, 2012 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. Quote Link to comment Share on other sites More sharing options...
salvador21 Posted December 9, 2012 Author Share Posted December 9, 2012 I tried that, many thanks. But nothing changed, still no notice on the product in the category page. Quote Link to comment Share on other sites More sharing options...
bsmither Posted December 9, 2012 Share Posted December 9, 2012 The skin file could be cached by Smarty. You didn't mention if you had cleared the cache (admin, Maintenance, Rebuild tab, Clear Cache checkbox). Quote Link to comment Share on other sites More sharing options...
salvador21 Posted December 9, 2012 Author Share Posted December 9, 2012 Thanks, tried that but still not there: http://tamingthesaxophone.com/store/accessories.html (second item down) Quote Link to comment Share on other sites More sharing options...
bsmither Posted December 10, 2012 Share Posted December 10, 2012 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. Quote Link to comment Share on other sites More sharing options...
salvador21 Posted December 10, 2012 Author Share Posted December 10, 2012 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. No, but I must have done something wrong, it's working now. Thanks you're a star! Quote Link to comment Share on other sites More sharing options...
salvador21 Posted December 11, 2012 Author Share Posted December 11, 2012 I am unable to like the help you've given me: You have reached your quota of positive votes for the day Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.