Ok so having a saturday blonde moment.
What is the correct way to hide products price on the product info page if the product has a price of 0.00?
I have tried (shortened example to keep it simple)
<?php if ($products_price == '0' ) {
echo PI_TEXT_PRODUCT_BEING_UPDATED;
}else{
<show products price code>
?>
Saying of the day 'Its the little things that make the brain hurt the most'
Thanks
Mark
What is the correct way to hide products price?
- tessthepup
- Certified Developer
- Posts: 383
- Joined: Mon Mar 01, 2021 5:55 pm
- Phoenix Version:
- Has thanked: 47 times
- Been thanked: 62 times
-
ecartz
- Core Team
- Posts: 3084
- Joined: Tue Nov 05, 2019 6:02 pm
- Phoenix Version:
- Has thanked: 4 times
- Been thanked: 208 times
Re: What is the correct way to hide products price?
Assuming that you are using the content module to show the price: https://github.com/CE-PhoenixCart/Phoen ... p#L24..L29
Change that block of code to look likeAll the normal comments apply. E.g. it is more robust to copy the module and edit the copy than to modify the core module. Make sure that the text constant is defined before you attempt to use it. Etc.
Change that block of code to look like
Code: Select all
if ($product->get('price') == '0' ) {
$price = PI_TEXT_PRODUCT_BEING_UPDATED;
}else{
$price = $product->get('is_special')
? sprintf(MODULE_CONTENT_PI_PRICE_DISPLAY_SPECIAL,
$product->format(),
$product->format('price'))
: sprintf(MODULE_CONTENT_PI_PRICE_DISPLAY,
$product->format());
}- tessthepup
- Certified Developer
- Posts: 383
- Joined: Mon Mar 01, 2021 5:55 pm
- Phoenix Version:
- Has thanked: 47 times
- Been thanked: 62 times
Re: What is the correct way to hide products price?
@ecartz
Hi Matt,
The code I am trying to hide
https://olivias-gifts.co.uk/500ml-pure- ... -2506.html
but I get this error
Also any ideas on why I can not seem to get the button to align perfectly to the right of the input field. I have tried all sorts of different ways and it does not move urgh
Hi Matt,
The code I am trying to hide
https://olivias-gifts.co.uk/500ml-pure- ... -2506.html
Code: Select all
<?php
if ($product->get('price') == '0' ) {
$price = PI_TEXT_PRODUCT_BEING_UPDATED;
}else{
?>
<div class="d-flex justify-content-start border">
<div class="pt-1"><?php echo 'Qty: </span>'; ?></div>
<div class="ml-2"><?php echo (new Input('qty', ['min' => '1', 'class' => 'form-control col-4', 'id' => 'pi-qty-input'], 'number'))->default_value('1'); ?></div>
<div class="btn-buy rounded"><?php echo tep_draw_button((tep_not_null($specials_price)) ? sprintf(PI_CONTENT_PI_PRICE_DISPLAY_SPECIAL, $specials_price, '' . $products_price) : sprintf(PI_CONTENT_PI_PRICE_DISPLAY, '' . $products_price), '', null, 'primary', array('params' => 'data-has-attributes="' . (($products_attributes['total'] > 0) ? '1' : '0') . '" data-in-stock="' . (int)$product_info['products_quantity'] . '" data-product-id="' . (int)$product_info['products_id'] . '"'), 'btn-success btn-product-info btn-buy'); ?></div>
<div><?php echo tep_draw_hidden_field('products_id', (int)$product_info['products_id']); ?></div>
</div>
<?php } ?>Ignore the deprecated functions as I am working on them.PHP Fatal error: Uncaught Error: Call to a member function get() on null
Also any ideas on why I can not seem to get the button to align perfectly to the right of the input field. I have tried all sorts of different ways and it does not move urgh
-
ecartz
- Core Team
- Posts: 3084
- Joined: Tue Nov 05, 2019 6:02 pm
- Phoenix Version:
- Has thanked: 4 times
- Been thanked: 208 times
Re: What is the correct way to hide products price?
Try going back to your original code and change to I'm not going to be able to give more help, as I don't really recall exactly how things worked in older versions.
Code: Select all
<?php if ('0' == $product_info['products_price'] ) {
echo PI_TEXT_PRODUCT_BEING_UPDATED;
}else{
<show products price code>
?>- tessthepup
- Certified Developer
- Posts: 383
- Joined: Mon Mar 01, 2021 5:55 pm
- Phoenix Version:
- Has thanked: 47 times
- Been thanked: 62 times
Re: What is the correct way to hide products price?
@ecartzecartz wrote: ↑Sun Apr 02, 2023 3:15 pm Try going back to your original code and change toI'm not going to be able to give more help, as I don't really recall exactly how things worked in older versions.Code: Select all
<?php if ('0' == $product_info['products_price'] ) { echo PI_TEXT_PRODUCT_BEING_UPDATED; }else{ <show products price code> ?>
Thanks Matt, a great help as usual
- burt
- Core Team
- Posts: 4560
- Joined: Tue Oct 29, 2019 9:37 am
- Phoenix Version: v1.1.0.8
- : Buy Me A Beverage
- Has thanked: 252 times
- Been thanked: 413 times
Re: What is the correct way to hide products price?
Don't forget that the price shows elsewhere (boxes and content modules). The simplest way to find them all is to run a search for "is-product" as this will find all the places where a product shows.
You can then override the files appropriately; if on a fairly up-to-date version of Phoenix a lot of them would be covered by /templates/{your template}/includes/components/product_card.php
You can then override the files appropriately; if on a fairly up-to-date version of Phoenix a lot of them would be covered by /templates/{your template}/includes/components/product_card.php
I am not here to build for you.
I am here to build with you. Let's help each other.
I am here to build with you. Let's help each other.
- tessthepup
- Certified Developer
- Posts: 383
- Joined: Mon Mar 01, 2021 5:55 pm
- Phoenix Version:
- Has thanked: 47 times
- Been thanked: 62 times
Re: What is the correct way to hide products price?
@burtburt wrote: ↑Mon Apr 03, 2023 2:49 pm Don't forget that the price shows elsewhere (boxes and content modules). The simplest way to find them all is to run a search for "is-product" as this will find all the places where a product shows.
You can then override the files appropriately; if on a fairly up-to-date version of Phoenix a lot of them would be covered by /templates/{your template}/includes/components/product_card.php
Thanks Gary, I am on the latest version and the product card was next on the list