Page 1 of 1
Add product description above add to cart button
Posted: Tue Jul 11, 2023 12:47 pm
by maryjane
Hello phoenix fam!
Please I need your assistance. I want to add the product description info added to product when creating it to the space above the add to cart button on the product_info.php page.
I have attached a snapshot to illustrate what I mean. I hope this can be done with ease. Your assistance is much appreciated as always.
product info.jpg
Cheers!
Re: Add product description above add to cart button
Posted: Tue Jul 11, 2023 1:12 pm
by maryjane
I've tried to use the following but product description is not shown.
Code: Select all
<div class="col-sm-<?php echo $content_width; ?> cm-pi-description">
<div class="description">
<?php echo $product_description; ?>
</div>
</div>
<div class="col-sm-<?php echo $content_width; ?> pi-buy-button mt-2">
<?php
echo tep_draw_button(PI_BUY_BUTTON_TEXT, 'fas fa-shopping-cart', 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-block btn-lg btn-product-info btn-buy');
echo tep_draw_hidden_field('products_id', (int)$product_info['products_id']);
?>
</div>
This is in the tpl_pi_buy_button.php file.
Re: Add product description above add to cart button
Posted: Tue Jul 11, 2023 2:18 pm
by Kofod95
The product_info is modular, so you can go to your admin, find modules->content, find the description-module, and give it a sort order lower than the buy button.
If you are on a version with the PI-system (1.0.7.12 has it, but I don't remember when it was introduced to core), you could make a PI-description module, which would allow you more control over the exact positioning.
It's also possible to use the tpl-file like you tried, but I don't think it's recommended. If you want to do it that way, look at includes/modules/content/product_info/cm_pi_description.php to find the correct way to get the description in your version.
//Daniel
Re: Add product description above add to cart button
Posted: Tue Jul 11, 2023 2:39 pm
by maryjane
Kofod95 wrote: ↑Tue Jul 11, 2023 2:18 pm
The product_info is modular, so you can go to your admin, find modules->content, find the description-module, and give it a sort order lower than the buy button.
It's also possible to use the tpl-file like you tried, but I don't think it's recommended. If you want to do it that way, look at includes/modules/content/product_info/cm_pi_description.php to find the correct way to get the description in your version.
//Daniel
Thanks for feedback. However, changing the sort order in admin will not work for me as my change will be reflected in other places. I want the description to appear above the add to cart button specifically on the product info page. The description is already shown at the bottom of product. I don't need this twice on the same page.
All I need is how to retrieve the $product_description value and place it where I want but for some reason, it's not showing there. If I comment out the description value and manually add text to test, it is displayed.
Code: Select all
<div class="col-sm-<?php echo $content_width; ?> cm-pi-description">
<div class="description">
<?php //echo $product_description; ?>
Enter product description here ...
</div>
</div>
Re: Add product description above add to cart button
Posted: Tue Jul 11, 2023 2:41 pm
by burt
The simplest option here which would do precisely as you need, is the advice of @Kofod95 to utilise the layout (modular) aspect of the product_info page.
Depending on what version, what version are you on, you should have a modular product_info page either already installed, or ready to install. You then need 1 extra module to show the product description in the correct place in your layout.
There is a "PRO" version of Phoenix that (I think) has lots of extra product_info layout modules, I am pretty sure that one of them is a description layout module. If PRO is not suitable at this time, you would need to make a layout module to suit your needs - not difficult, you can base it on one of the other layout modules.
Re: Add product description above add to cart button
Posted: Tue Jul 11, 2023 2:42 pm
by burt
maryjane wrote: ↑Tue Jul 11, 2023 2:39 pm
I don't need this twice on the same page.
You would turn one module "on" and the other module "off".
All I need is how to retrieve the $product_description value and place it where I want but for some reason, it's not showing there.
This is not how coding works, sorry.
Re: Add product description above add to cart button
Posted: Tue Jul 11, 2023 2:49 pm
by maryjane
I got it working using this:
Code: Select all
<div class="col-sm-<?php echo $content_width; ?> cm-pi-description">
<div class="description">
<?php echo stripslashes($product_info['products_description']); ?>
</div>
</div>
It's all I needed. I'm not a coder or an expert like many of you nor do I seek to be one. I just need to get solutions to issues. My approach may not be your cup of tea, but I got my desired result.