How can I make the items price shown in the "Add to Cart" box?
How can I make the items price shown in the "Add to Cart" box?
Look in /includes/templates/your_template/templates/tpl_product_info_display.php for the regular price display code:Put the core of that in a div instead of h2, and insert it into the add to cart block in an appropriate place.PHP Code:<!--bof Product Price block -->
<h2 id="productPrices" class="productGeneral">
<?php
// base price
if ($show_onetime_charges_description == 'true') {
$one_time = '<span >' . TEXT_ONETIME_CHARGE_SYMBOL . TEXT_ONETIME_CHARGE_DESCRIPTION . '</span><br />';
} else {
$one_time = '';
}
echo $one_time . ((zen_has_product_attributes_values((int)$_GET['products_id']) and $flag_show_product_info_starting_at == 1) ? TEXT_BASE_PRICE : '') . zen_get_products_display_price((int)$_GET['products_id']);
?></h2>
<!--eof Product Price block -->
There are a number of locations in the add to cart code where the price code could go, depending on how you want it to display.PHP Code:<div id="productPricesAdd" class="productGeneral">
<?php
// base price
if ($show_onetime_charges_description == 'true') {
$one_time = '<span >' . TEXT_ONETIME_CHARGE_SYMBOL . TEXT_ONETIME_CHARGE_DESCRIPTION . '</span><br />';
} else {
$one_time = '';
}
echo $one_time . ((zen_has_product_attributes_values((int)$_GET['products_id']) and $flag_show_product_info_starting_at == 1) ? TEXT_BASE_PRICE : '') . zen_get_products_display_price((int)$_GET['products_id']);
?></div>
I'm now getting this error.
Parse error: syntax error, unexpected T_REQUIRE in /blah/blah/blah/templates/tpl_product_info_display.php on line 1
This is my code:
PHP Code:<?php
$display_qty = (($flag_show_product_info_in_cart_qty == 1 and $_SESSION['cart']->in_cart($_GET['products_id'])) ? '<p>' . PRODUCTS_ORDER_QTY_TEXT_IN_CART . $_SESSION['cart']->get_quantity($_GET['products_id']) . '</p>' : '');
if ($products_qty_box_status == 0 or $products_quantity_order_max== 1) {
// hide the quantity box and default to 1
$the_button = '<input type="hidden" name="cart_quantity" value="1" />' . zen_draw_hidden_field('products_id', (int)$_GET['products_id']) . zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT);
} else {
// show the quantity box
$the_button = PRODUCTS_ORDER_QTY_TEXT . '<input type="text" name="cart_quantity" value="' . (zen_get_buy_now_qty($_GET['products_id'])) . '" maxlength="6" size="4" /><br />' . zen_get_products_quantity_min_units_display((int)$_GET['products_id']) . '<br />' . zen_draw_hidden_field('products_id', (int)$_GET['products_id']) . zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT);
}
$display_button = zen_get_buy_now_button($_GET['products_id'], $the_button);
?>
<?php if ($display_qty != '' or $display_button != '') { ?>
<div id="productPrices" class="productGeneral">
<?php
// base price
if ($show_onetime_charges_description == 'true') {
$one_time = '<span >' . TEXT_ONETIME_CHARGE_SYMBOL . TEXT_ONETIME_CHARGE_DESCRIPTION . '</span><br />';
} else {
$one_time = '';
}
echo $one_time . ((zen_has_product_attributes_values((int)$_GET['products_id']) and $flag_show_product_info_starting_at == 1) ? TEXT_BASE_PRICE : '') . zen_get_products_display_price((int)$_GET['products_id']);
?></div>
<div id="cartAdd">
<?php
echo $display_qty;
echo $display_button;
?>
</div>
<?php } // display qty and button ?>
<?php } // CUSTOMERS_APPROVAL == 3 ?>
And you're getting this error on line 1 of tpl_product_info_display.php?
What does line 1 look like now?
Nothing jumps out at me in the code you posted, except that you are not supposed to have an id twice on a page, and should change the id="productPrices" as I showed above.
What did you use to edit the file? Some programs are known for mangling PHP code.
You are right, I use Notepad++ and it was saving all the php code in one giant line.
Now it is working but the price is not showing inside the "Add to Cart" box. It always shows above the products details. Is it a matter of placing the code in the correct place or do I have to add some extra code somewhere for the price to display inside the "Add to Cart" box?
Here is a link so you can see what I mean. http://csi-drives.com/index.php?main...products_id=65
I find Notepad++ to be excellent for editing PHP, but I suppose there are things you could tell it to do that would be bad for it.
The price code needs to be inside the add to cart div for them to stay together. Try moving the
<div id="cartAdd">
to just above the
<div id="productPricesAdd" class="productGeneral">
Beautiful my friend. It worked perfectly.
Thank you very much.