Zen Cart Logo
If this is your first visit, check our documentation. To post, register or login.
Forums / Configuring the Zen Cart Admin / Basic Configuration / Price in the "Add to Cart" box

Price in the "Add to Cart" box

Locked

Started by pochon on 26 Jun 2007, 11:41 PM · Views: 1,379

Results 1 to 7 of 7
This thread is locked. New replies are disabled.
26 Jun 2007, 11:41 PM
#1
pochon avatar

pochon

New Zenner

Join Date:
May 2007
Posts:
18
Plugin Contributions:
0

Post #1 by pochon

How can I make the items price shown in the "Add to Cart" box?

27 Jun 2007, 1:29 AM
#2
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,874
Plugin Contributions:
8

Post #2 by gjh42

Look in /includes/templates/your_template/templates/tpl_product_info_display.php for the regular price display code:```php

<!--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 --> ```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 <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> ```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.
27 Jun 2007, 5:47 PM
#3
pochon avatar

pochon

New Zenner

Join Date:
May 2007
Posts:
18
Plugin Contributions:
0

Post #3 by pochon

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

    $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 ?>
27 Jun 2007, 6:18 PM
#4
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,874
Plugin Contributions:
8

Post #4 by gjh42

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.

27 Jun 2007, 6:48 PM
#5
pochon avatar

pochon

New Zenner

Join Date:
May 2007
Posts:
18
Plugin Contributions:
0

Post #5 by pochon

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_page=product_info&cPath=1_17&products_id=65

27 Jun 2007, 8:27 PM
#6
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,874
Plugin Contributions:
8

Post #6 by gjh42

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">
27 Jun 2007, 9:11 PM
#7
pochon avatar

pochon

New Zenner

Join Date:
May 2007
Posts:
18
Plugin Contributions:
0

Post #7 by pochon

Beautiful my friend. It worked perfectly.
:clap:Thank you very much.