Zen Cart Logo
If this is your first visit, check our documentation. To post, register or login.
Forums / General Questions / General Questions / Displaying the product's total price on product info display page?

Displaying the product's total price on product info display page?

Started by clam_man on 29 Aug 2019, 8:15 PM · Views: 4,519

Results 1 to 7 of 7
29 Aug 2019, 8:15 PM
#1
clam_man avatar

clam_man

New Zenner

Join Date:
Jun 2019
Location:
Austin TX
Posts:
65
Plugin Contributions:
0

Post #1 by clam_man

I'd like to display the product's total price (starting at price + sum of selected attribute prices) in the 'Add to Cart Box'. I looked at the attributes.php module and checked out the tpl_shopping_cart.php files but can't wrap my head around how to display this info. Does anyone know of a solution? We are getting complaints from customers about not knowing how much a product is before adding it to their cart. Our products can sometimes have upwards of 15 attributes and the customers don't want to manually add it up in their head or check out the cart page with the product added.

30 Aug 2019, 12:03 AM
#2
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,915
Plugin Contributions:
24

Post #2 by dbltoe

Checkout the Dynamic Price Updater Mod at https://www.zen-cart.com/downloads.php?do=file&id=1301.

Example at https://allpecans.com/index.php?main_page=product_info&cPath=34&products_id=117

Select a size then, press the down arrow through the selections. Notice the price changes in the Price Breakdown sidebox and at the Your Price.

Need a hand with Zen Cart? Hire the team at myZenCartZone.com for upgrades, repairs, and custom plugins.
Zen Cart Certified hosting at myZenCartHost.com

30 Aug 2019, 6:12 PM
#3
clam_man avatar

clam_man

New Zenner

Join Date:
Jun 2019
Location:
Austin TX
Posts:
65
Plugin Contributions:
0

Post #3 by clam_man

Is this compatible with version 1.5.6?

3 Sep 2019, 11:53 AM
#4
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Post #4 by mc12345678

clam_man:

Is this compatible with version 1.5.6?
Yes it is. The compatibility though would depend more on your template than anything. There are settings in the configuration section to help. Also, since the module uses javascript, would suggest verifying that your product information pages already pass html validation before adding the module.

If there are any issues with its use, would suggest posting to the forum help thread provided in the download link given by dbltoe.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

3 Sep 2019, 8:36 PM
#5
clam_man avatar

clam_man

New Zenner

Join Date:
Jun 2019
Location:
Austin TX
Posts:
65
Plugin Contributions:
0

Post #5 by clam_man

I saw that it was going to make changes to the database for some reason so I decided against installing it. It took a few hours, but 51 lines of JavaScript later, I've got exactly what I wanted. I used regular expressions on the selected radio labels and drop-down options to sum those associated costs with the starting price of the product. If anyone is interested in more about how I did this, feel free to PM me! It even works with MAP pricing.

3 Sep 2019, 8:54 PM
#6
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Post #6 by mc12345678

clam_man:

I saw that it was going to make changes to the database for some reason so I decided against installing it. It took a few hours, but 51 lines of JavaScript later, I've got exactly what I wanted. I used regular expressions on the selected radio labels and drop-down options to sum those associated costs with the starting price of the product. If anyone is interested in more about how I did this, feel free to PM me! It even works with MAP pricing.

Nothing like redesigning the wheel. Yes, it makes changes to the database by adding it's own configuration options. It doesn't affect core database values but allows the store owner to turn on/off features, to assign html id/class information to which to associate, whether a sidebox should be made available, etc...
Hopefully you have considered the cases where an attribute may not be on sale when the product is on sale, that the attribute is free/or not when the product is free, whether the attribute is part of the base price, required, etc...

Also, be advised, that in the majority of cases, if you think you have a viable program, might as well package it up and provide it as a plugin. There are those that may reach out to you about this, but as an open source platform, sharing the solution is considered the way to go.

Congrats on developing your solution.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

3 Sep 2019, 9:40 PM
#7
clam_man avatar

clam_man

New Zenner

Join Date:
Jun 2019
Location:
Austin TX
Posts:
65
Plugin Contributions:
0

Post #7 by clam_man

I am interested in publishing this solution if possible but I definitely would have some changes to make to the code before that would be possible. I'm great with PHP and great with MySQL but not necessarily great with the merging of the two. Currently there's a couple template changes I had to make to give the quantity_box an ID so it could be referenced and give it an onkeyup function and I made changes to includes/modules/attributes.php to add 'onchange' functions to the radio buttons and dropdown menus. I am currently using integers of the max option name IDs to run my loop but I'd love to find out how to pull that data from the database so this is more scalable and usable by others without the user having to set it up to be unique for their store's database. Currently this solution is all JS but I can probably translate it to PHP if necessary. The only other thing I'm not checking for which, might be a problem for other stores, is for option values that include a currency sign in them. None of our tens of thousands of attributes include dollar signs so I didn't have to include that functionality with the regular expression I came up with.