afalls Posted April 6, 2013 Share Posted April 6, 2013 I am currently setting up my first cubecart (It will run in catalog mode only). Of the products, 70% have prices and the other 30% you need to contact the company directly for a price. I didn't want the price to appear as $0.00 so following another topic in the forums i changed the code so on products with no prices it displays as "POA". This is working perfectly. For the products with prices, I need it to display as "$24.95 + GST" and i managed to do this by hard coding in the "+ GST". The issue i now have is for the products with no price i get "POA + GST" How can i get the "+ GST" to only appear where there is an actual price? Any help would be greatly appreciated. (I am using CubeCart-5.2.1 and its a clean install) Quote Link to comment Share on other sites More sharing options...
bsmither Posted April 6, 2013 Share Posted April 6, 2013 Welcome afalls! Glad to see you made it to the forums. Where did you hard-code the +GST? If in the skin files, we can use some display logic to only add the +GST if the product price is not "POA". If in the class files, we can test for an 'empty' value (PHP treats 0 as empty) and deal with it there. CubeCart makes available a "display price" that is a string and comes with a currency symbol. But there is also available the actual price with is a float. Quote Link to comment Share on other sites More sharing options...
afalls Posted April 6, 2013 Author Share Posted April 6, 2013 Thanks so much for your speedy response bsmither. I hard coded in the skin files. It was the below code in the content.product.php. <div id="price"> <p>{if $PRODUCT.ctrl_sale}</p> <h1><span class="price_previous">{$PRODUCT.price} + GST</span><span class="price_sale">{$PRODUCT.sale_price}</span> + GST</h1> {else} <h1>{$PRODUCT.price} + GST</h1> {/if} </div> If you can guide me as to what logic i need here that would be brilliant. Thanks again. Quote Link to comment Share on other sites More sharing options...
bsmither Posted April 6, 2013 Share Posted April 6, 2013 We will use these: $PRODUCT.price_unformatted $PRODUCT.sale_price_unformatted If these are not empty, so to speak, will print the +GST. <h1><span class="price_previous">{$PRODUCT.price} {if !empty($PRODUCT.price_unformatted)}+ GST{/if}</span><span class="price_sale">{$PRODUCT.sale_price} {if !empty($PRODUCT.sale_price_unformatted)}+ GST{/if}</span></h1> <h1>{$PRODUCT.price}{if !empty($PRODUCT.price_unformatted)} + GST{/if}</h1> Quote Link to comment Share on other sites More sharing options...
Guest hilla4g Posted April 6, 2013 Share Posted April 6, 2013 Hi - this is exactly what I need to do - I just need POA throughout the store for the moment. I have altered content.product.php and that's great. Which file is the product summary in though? When I click on the 'show all doors' etc, I still get the prices showing through? I just need to replace that too but I can't find it? Cheers! Quote Link to comment Share on other sites More sharing options...
bsmither Posted April 6, 2013 Share Posted April 6, 2013 "Show all doors"? What's that? Quote Link to comment Share on other sites More sharing options...
Guest hilla4g Posted April 6, 2013 Share Posted April 6, 2013 Sorry - wasn't clear enough - if I selected a Category from the Homepage (my Category was called 'Doors') then I'd get a list of products with prices (summary page) and I need POA on there too. Since posting I've found it - it's in content.category.php and also content.homepage.php Thank you so much for the quick reply though , really appreciated! Cheers Quote Link to comment Share on other sites More sharing options...
Guest hilla4g Posted April 6, 2013 Share Posted April 6, 2013 Am just looking at this a bit more, is it possible to have prices on all manufacturers apart from one, and have that manufacturer as POA? I have one supplier who do not wish their prices to be put online, but everyone else is ok. Would it be possible to alter the <h1>{$PRODUCT.price}</h1> code with something bespoke to allow this? Quote Link to comment Share on other sites More sharing options...
bsmither Posted April 6, 2013 Share Posted April 6, 2013 You can do the same type of thing with $PRODUCT.manufacturer. You will need to know the ID number of the manufacturer. You can get that by using the admin list of manufacturers, then by placing the mouse cursor over the edit icon. The browser will show you the URL that this link will go to. In the URL, you will see ...edit=9... where 9 is the actual ID number of that manufacturer. <h1>{if $PRODUCT.manufacturer == 9}POA{else}{$PRODUCT.price}{if !empty($PRODUCT.price_unformatted)} + GST{/if}{/if}</h1> I do not know if the .manufacturer is available for all instances. But this isn't really a display logic problem. Alongside the test for "Hide prices until customer logged in" would be the best place to add this additional test - in the PHP controller code. Probably exactly where you have already made the "If zero, use POA" adjustment. Quote Link to comment Share on other sites More sharing options...
afalls Posted April 7, 2013 Author Share Posted April 7, 2013 Hi there, I think i must be doing something wrong as i am still getting "POA + GST" after i added in the below code as suggested: Posted Today, 01:28 AM We will use these: $PRODUCT.price_unformatted $PRODUCT.sale_price_unformatted If these are not empty, so to speak, will print the +GST. <h1><span class="price_previous">{$PRODUCT.price} {if !empty($PRODUCT.price_unformatted)}+ GST{/if}</span><span class="price_sale">{$PRODUCT.sale_price} {if !empty($PRODUCT.sale_price_unformatted)}+ GST{/if}</span></h1> <h1>{$PRODUCT.price}{if !empty($PRODUCT.price_unformatted)} + GST{/if}</h1> __________ Is this because i have the code for converting $0.00 to POA in catelogue.class.php as below: $product['price_unformatted'] = $product['price']; $product['sale_price_unformatted'] = $product['sale_price']; if ($product['price'] == "0.00") { $product['price'] = "POA"; Quote Link to comment Share on other sites More sharing options...
bsmither Posted April 7, 2013 Share Posted April 7, 2013 If I had a nickel for every time I forgot to mention this: Since we modified the skin code, we must clear the skin cache. CubeCart keeps a rendered version of each skin template for quicker data population and delivery. Admin, Maintenance, Rebuild tab, Clear Cache. I hope that is the issue. Because it should work. Quote Link to comment Share on other sites More sharing options...
afalls Posted April 7, 2013 Author Share Posted April 7, 2013 damn...I cleared cache but unfortunately its still not working. I've double checked everything but it all looks like you have said to do. I'll have another look back through my files to triple check now. Would there be anything else i should be checking? Sorry to be difficult. Quote Link to comment Share on other sites More sharing options...
afalls Posted April 7, 2013 Author Share Posted April 7, 2013 I've been trying a number of things and still no luck but i am wondering if i should try and do this through classes not skin - would this work? To get the "POA" to appear i edited the catalogue.class.php and cubecart.cless.php files as follows: Original code: $product['price'] = $GLOBALS['tax']->priceFormat($product['price']); Edited code: if ($product['price'] == "0.00") {$product['price'] = "POA";} else {$product['price'] = $GLOBALS['tax']->priceFormat($product['price']); } Quote Link to comment Share on other sites More sharing options...
bsmither Posted April 7, 2013 Share Posted April 7, 2013 Wow. I just learned that the template rendering engine imposes quite a bit on what simple PHP you can use in the templates. My suggestion of using !empty() won't work because Smarty (the engine) converts the Smarty variables to objects. And Smarty objects are rarely empty. Plus the fact that I was wrong in that PHP considers the string "0" as empty, but not the string "0.00". So I thought to convert the string to its float number equivalent and then test for empty. Again, converting what has become an object is illegal. So, to do what we need to do in the template is make a direct comparison of the price_unformatted variable (which is also a string) to "0.00". <h1>{$PRODUCT.price}{if $PRODUCT.price_unformatted ne "0.00"} + GST{/if}</h1> On the other hand, as you commented, we can made a small edit to Catalogue->productAssign() where you made your initial edit. Knowing that you want only POA if the product price is "0.00", otherwise the actual price followed by "+GST", we can change this: $product['price'] = $GLOBALS['tax']->priceFormat($product['price']); to this: $product['price'] = $GLOBALS['tax']->priceFormat($product['price'] . " + GST"); Doing this means edits to the skin would be undesirable. Quote Link to comment Share on other sites More sharing options...
afalls Posted April 8, 2013 Author Share Posted April 8, 2013 Hi there. Just wanted to let you know that its now working perfectly. I ended up using <h1>{$PRODUCT.price}{if $PRODUCT.price_unformatted ne "0.00"} + GST{/if}</h1> in the skin and its exactly what i was after from the beginning. Thanks again for you help! Quote Link to comment Share on other sites More sharing options...
Guest hilla4g Posted April 8, 2013 Share Posted April 8, 2013 Hi - I've used this line: {if $PRODUCT.manufacturer == 1}£ P.O.A.{else}{$PRODUCT.price}{/if} on content.product.php and the result was perfect. POA displayed when my manufacturer was 1, and the real price displayed for all other brands. However the same code in content.homepage.php and content.category.php doesn't work - there's just a blank inserted into the display. Is this because .manufacturer is not available in these templates? Cheers! Quote Link to comment Share on other sites More sharing options...
bsmither Posted April 8, 2013 Share Posted April 8, 2013 "Is this because .manufacturer is not available in these templates?" Probably is available. You didn't mention if you were careful to match the part of the variable other than .manufacturer. The Latest Products area of the the Homepage and the View Category page uses $product.manufacturer (note the lowercase product). In addition, if the price is to display as POA, then you may need to consider disallowing the product to be placed in the shopping basket since prices are displayed there. Quote Link to comment Share on other sites More sharing options...
Guest hilla4g Posted April 8, 2013 Share Posted April 8, 2013 Perfect, thank you so much. Lowercase product.manufacturer was the solution. I take your point about the basket - thank you. However I can't find anything in the CP that will allow the product to exist as a POA but disable the Add to Basket - am I looking straight through it or is it a complex mod? Quote Link to comment Share on other sites More sharing options...
bsmither Posted April 8, 2013 Share Posted April 8, 2013 It's not so complex. In content.product.php, notice this series of 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 you are not allowed to buy it, then either you must be logged in or the product is out of stock. We can use this statement: {if ($CTRL_ALLOW_PURCHASE) && (!$CATALOGUE_MODE)} to add another test: {if ( ($CTRL_ALLOW_PURCHASE) && (!$CATALOGUE_MODE)) || $PRODUCT.manufacturer != 1 )} We have added a phrase "or the manufacturer is not 1". If true (that is, not equal to 1), then we will show the add to basket buttons. If false (that is, if equal to 1), then the else part comes into play. But since hiding prices and out of stock may not be pertinent, we could add another else-if response or just let it be blank. Quote Link to comment Share on other sites More sharing options...
Guest hilla4g Posted April 9, 2013 Share Posted April 9, 2013 Thank you - I understand the logic and it's a really neat solution. There was a minor syntax (in case anyone else is helped by this thread) - a missing ( and the page now displays but the Add to Basket is still there? What else have I missed? Thank you! {if (($CTRL_ALLOW_PURCHASE) && (!$CATALOGUE_MODE)) || ($PRODUCT.manufacturer != 1 )} Quote Link to comment Share on other sites More sharing options...
bsmither Posted April 9, 2013 Share Posted April 9, 2013 Stupid logic error. Let the manufacturer be 1 so that the buy button is inhibited. If we are allowed to purchase (true) and we are not in catalogue mode (true) = true or If manufacturer is not 1 (false) ======= still true (not what we want) {if (($CTRL_ALLOW_PURCHASE) && (!$CATALOGUE_MODE)) && ($PRODUCT.manufacturer != 1 )} If we are allowed to purchase (true) and we are not in catalogue mode (true) = true and If manufacturer is not 1 (false) ======= false (what we want) Quote Link to comment Share on other sites More sharing options...
Guest hilla4g Posted April 9, 2013 Share Posted April 9, 2013 Perfect. Many many thanks, really appreciate all the help and expertise! 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.