Forums / Templates, Stylesheets, Page Layout / adding an asterisk to zen_get_products_display_price((int)

adding an asterisk to zen_get_products_display_price((int)

Started by the_mech on 19 Feb 2012, 11:42 PM · Views: 1,375

Results 1 to 13 of 13
19 Feb 2012, 11:42 PM
#1
the_mech avatar

the_mech

New Zenner

Join Date:
Feb 2012
Posts:
67
Plugin Contributions:
0

adding an asterisk to zen_get_products_display_price((int)

My goal is to make it so that there is an asterisk after the price.
ie: $36.98*

I have managed to do this without having a sale in place. However, if there is a sale, the asterisk becomes

$28.99
22% off*

The code I need to modify is:
zen_get_products_display_price((int)$_GET['products_id']) ;

I don't know how to get a . '*' . in there without it creating an error. My cache didn't pick anything up which is frustrating in itself. Can someone please help.

Thanks!

20 Feb 2012, 1:53 AM
#2
the_mech avatar

the_mech

New Zenner

Join Date:
Feb 2012
Posts:
67
Plugin Contributions:
0

Re: adding an asterisk to zen_get_products_display_price((int)

please help

20 Feb 2012, 2:14 AM
#3
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: adding an asterisk to zen_get_products_display_price((int)

Look around line 261 and see if this does what you are looking for:

    if ($display_normal_price == 0) {
      // don't show the $0.00
      $final_display_price = $show_special_price .  $show_sale_price . $show_sale_discount;
    } else {
      $final_display_price = $show_normal_price . ($show_sale_discount != '' ? '*' : '') . $show_special_price . $show_sale_price . $show_sale_discount;
    }

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

20 Feb 2012, 3:33 AM
#4
the_mech avatar

the_mech

New Zenner

Join Date:
Feb 2012
Posts:
67
Plugin Contributions:
0

Re: adding an asterisk to zen_get_products_display_price((int)

Perfect. Once again Ajeh, you are amazing.

20 Feb 2012, 4:14 AM
#5
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: adding an asterisk to zen_get_products_display_price((int)

You are most welcome ... thanks for the update that this worked for you ... :smile:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

2 Mar 2012, 1:07 PM
#6
mikeyg avatar

mikeyg

Totally Zenned

Join Date:
May 2005
Posts:
515
Plugin Contributions:
0

Re: adding an asterisk to zen_get_products_display_price((int)

Ajeh,

I am trying to use the zen_get_products_display_price function in a similar way on my product listing page.

if the price is above a certain amount eg £20 then display a message - free delivery.

2 questions. in the file modules/product_listing.php the $lc_price seems to be a text string I have trimmed the £ and converted it to an integer and this seems to work for the product with out a special - ie I get my message. but if there is a sale or a special then the text does not appear. If I understand the function correctly after all its actions it retuns the $final_display_price which is passed to $lc_price.

I am assuming that this must be a string with more than just the price (ie it must have the original price and the sale price in it.

Should I be trying to append my message in the function or in the module and if in the module how can I get the final sale price out of the function so my free delivery message shows / or does not show if the sale price goes below my value.

my code is currently in the product_listing.php file as:

case 'PRODUCT_LIST_PRICE':
$lc_price = zen_get_products_display_price($listing->fields['products_id']) . '<br />';
//if ($listing->fields['products_price'] >= '13.88' ) {$lcpricetext = '<a>Free UK delivery</a>'; } else {$lcpricetext = "";}
$mylcprice = trim($lc_price,£);
settype($myclprice, "integer");
if ($mylcprice >=12) {$lcpricetext = '<a>Free UK delivery</a>'; } else {$lcpricetext = "";}
$lc_align = 'left';
$lc_text = '<span id="productListingprice">'. //PRODUCT_LISTING_PRICE_TEXT .
$lc_price . $lcpricetext. '</span>';

2 Mar 2012, 2:02 PM
#7
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: adding an asterisk to zen_get_products_display_price((int)

The values for the normal, sale and special price are set in:

    $display_normal_price = zen_get_products_base_price($products_id);
    $display_special_price = zen_get_products_special_price($products_id, true);
    $display_sale_price = zen_get_products_special_price($products_id, false);

You could use those 3 to determine what the real price is without the text added to them then calculate which is the lowest price to manage your message ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

2 Mar 2012, 2:20 PM
#8
mikeyg avatar

mikeyg

Totally Zenned

Join Date:
May 2005
Posts:
515
Plugin Contributions:
0

Re: adding an asterisk to zen_get_products_display_price((int)

Ajeh,

Thank you for this pointer. As I am not a true developer, more a business owner trying to find his way.

should I be using these and creating a new function in the function_prices file to detemine the price or can I call them from the module product_listing and work it out there. A question of best practice really and then I can go away and work it out.

Thanks

2 Mar 2012, 2:33 PM
#9
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: adding an asterisk to zen_get_products_display_price((int)

If you only want that on the product_listing.php module then you could use another function in there, example test:

        case 'PRODUCT_LIST_PRICE':
        echo 'Actual Price: ' . zen_get_products_actual_price($listing->fields['products_id']) . '<br>';
        $lc_price = zen_get_products_display_price($listing->fields['products_id']) . '<br />';
        $lc_align = 'right';
        $lc_text =  $lc_price;

that should give you the actual product price without converting it to currency format and help take the work out of it ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

2 Mar 2012, 3:12 PM
#10
mikeyg avatar

mikeyg

Totally Zenned

Join Date:
May 2005
Posts:
515
Plugin Contributions:
0

Re: adding an asterisk to zen_get_products_display_price((int)

Ajeh,

Thank you. That does the trick - zen_get_products_actual_price($listing->fields['products_id'])

I have equated my variable to zen_get_products_actual_price($listing->fields['products_id']) and then kept the same code as I originally had to determine if the text should show or not.

The one minor issue is that this is a net value and therefore on products such as clothes without VAT it will mean the text shows at a slighty lower price ie a £15 item gets free carriage which in the equation is 12.50 net but a 12.50 childs t-shirt will get free carriage. -

I had a look through the price functions and could not see one that would produce the actual price including tax.

Does that make sense? Hope so and thank you again for you quick responses.

2 Mar 2012, 3:33 PM
#11
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: adding an asterisk to zen_get_products_display_price((int)

I am not sure if this will help you or not:

        case 'PRODUCT_LIST_PRICE':
        $chk_product_price = zen_get_products_actual_price($listing->fields['products_id']);
        $chk_tax_class_id = zen_products_lookup($listing->fields['products_id'], 'products_tax_class_id');
        $product_price_tax = $currencies->display_price($chk_product_price, $chk_tax_class_id);
        echo 'Actual Price: ' . $chk_product_price . ' - with tax: ' . $product_price_tax . '<br>';
        $lc_price = zen_get_products_display_price($listing->fields['products_id']) . '<br />';
        $lc_align = 'right';
        $lc_text =  $lc_price;

Now you are back to needing to strip out the text on the:
$product_price_tax

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

2 Mar 2012, 3:58 PM
#12
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: adding an asterisk to zen_get_products_display_price((int)

Note: you could add another function to the currencies.php class:

  function display_price($products_price, $products_tax, $quantity = 1) {
    return $this->format(zen_add_tax($products_price, $products_tax) * $quantity);
  }

  function display_price_clean($products_price, $products_tax, $quantity = 1) {
    return zen_add_tax($products_price, $products_tax) * $quantity;
  }

That can get you the price with the tax but not the currency format ...

Then test it in the product_listing.php

        case 'PRODUCT_LIST_PRICE':
        $chk_product_price = zen_get_products_actual_price($listing->fields['products_id']);
        $chk_tax_class_id = zen_products_lookup($listing->fields['products_id'], 'products_tax_class_id');
        $product_price_tax = $currencies->display_price($chk_product_price, $chk_tax_class_id);
        $product_price_tax_clean = $currencies->display_price_clean($chk_product_price, $chk_tax_class_id);
        echo 'Actual Price: ' . $chk_product_price . ' - with tax: ' . $product_price_tax . ' clean w/tax: ' . $product_price_tax_clean . '<br>';
        $lc_price = zen_get_products_display_price($listing->fields['products_id']) . '<br />';
        $lc_align = 'right';
        $lc_text =  $lc_price;

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

2 Mar 2012, 5:01 PM
#13
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: adding an asterisk to zen_get_products_display_price((int)

Actually, I think I have a boo boo on those last two posts ...

Try this code instead after adding the new function to the currencies.php

        case 'PRODUCT_LIST_PRICE':
        $chk_product_price = zen_get_products_actual_price($listing->fields['products_id']);
        $chk_tax_class_id = zen_products_lookup($listing->fields['products_id'], 'products_tax_class_id');
        $product_price_tax = $currencies->display_price($chk_product_price, zen_get_tax_rate($chk_tax_class_id));
        $product_price_tax_clean = $currencies->display_price_clean($chk_product_price, zen_get_tax_rate($chk_tax_class_id));
        echo 'Actual Price: ' . $chk_product_price . ' - with tax: ' . $product_price_tax . ' with tax clean:' . $product_price_tax_clean . ' display: ' . zen_get_products_display_price($listing->fields['products_id']) . '<br>';
        $lc_price = zen_get_products_display_price($listing->fields['products_id']) . '<br />';

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!