If this is your first visit, check our documentation. To post, register or login.
Forums / Setting Up Categories, Products, Attributes / Create a custom attribute - Price Translation

Create a custom attribute - Price Translation

Started by djdavedawson on 5 May 2022, 9:33 PM · Views: 2,715

Results 1 to 6 of 6
5 May 2022, 9:33 PM
#1
djdavedawson avatar

djdavedawson

Zen Follower

Join Date:
Jul 2005
Location:
Orlando, Fl
Posts:
343
Plugin Contributions:
0

Create a custom attribute - Price Translation

I'd like to create a custom attribute based off the existing text attribute model.

I want this new attribute to display a text box where I could input a price into the field.

Then once it is added to cart it would set the item price to what was entered in the attribute field.

I'm thinking ... duplicating the current text item attribute then modifying it so that action=add_product would identify the new attribute and set the price accordingly. Somewhat like how the price by words works.

Hoping someone could point me in the right direction to accomplish this.

Thanks in Advance

~D

5 May 2022, 10:07 PM
#2
dbltoe avatar

dbltoe

Totally Zenned

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

Re: Create a custom attribute - Price Translation

Can you give us a little more explanation of what the goal and the process consist of that differs from the standard "priced by attributes" method that's in place?

https://docs.zen-cart.com/user/products/attribute_pricing/#product-priced-by-attributes-vs-attributes-with-prices

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

5 May 2022, 10:58 PM
#3
djdavedawson avatar

djdavedawson

Zen Follower

Join Date:
Jul 2005
Location:
Orlando, Fl
Posts:
343
Plugin Contributions:
0

Re: Create a custom attribute - Price Translation

The goal would be to submit an item to the shopping cart at any price on the fly from the front-end of the website. With the price by attributes method, I would need to create an option value for every price. For example $1 $2 $3 ..... $5000. This would work but would be a bit bloated for its intention. Now I could create an option name for 1000's, 100s, 10s, & 1s. But then that creates a mess on the shopping cart page.

5 May 2022, 11:06 PM
#4
dbltoe avatar

dbltoe

Totally Zenned

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

Re: Create a custom attribute - Price Translation

Forgive my confusion but, if I get it correctly, how would you prevent anyone logged in from putting in any price they liked?

I've seen products set up as unit price of .01 to allow bill paying (1995 being $19.95) and know Edit Orders can change prices in the back end but, changing from the front end......

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

5 May 2022, 11:09 PM
#5
djdavedawson avatar

djdavedawson

Zen Follower

Join Date:
Jul 2005
Location:
Orlando, Fl
Posts:
343
Plugin Contributions:
0

Re: Create a custom attribute - Price Translation

It would be IP controlled.

6 May 2022, 12:45 PM
#6
balihr avatar

balihr

Totally Zenned

Join Date:
Oct 2008
Location:
Croatia
Posts:
1,817
Plugin Contributions:
24

Re: Create a custom attribute - Price Translation

I've done something similar in my POS plugin so I'll share the basic idea. However, it's up to you to adapt it to what you're after because I'm setting the custom price through a different method, not even close to what you're trying to do.
I believe you could use extra_cart_actions to override the standard action=add_product when the custom attribute field is submitted. Then, you can set a price for that item based on your input field (store it to session), and then edit includes/classes/shopping_cart.php just before $productTotal += $products_price; to override any previously determined product price and set your own based on what you have stored in session earlier.

My site - Pro ZC Help
My portfolio | My plugins