hellboy Posted May 8, 2018 Share Posted May 8, 2018 Hello all, I want to store some Userdata for a shopping cart. I want to do it in the user database and retrieve it from there. what i have now is a Link button and there i want to store a Productnumber for the logged in user. What i want is: Userdatabase -> shoppingcart->items, amount is this possible? Cheers Link to comment Share on other sites More sharing options...
Ivan Gretsky Posted May 8, 2018 Share Posted May 8, 2018 Welcome to the forums, @hellboy! As I can understand, you want to store the content of the last (or maybe more than one) abandoned shopping cart in the db, so retuning customers can continue the purchase. This is all possible with ProcessWire. But PW does not have shopping cart feature out of the box, so I guess you either bought Padloper module or crafted something yourself. Not sure about all those terms you use like 'Userdatabase' and stuff. Could you explain a little bit, how are products stored within your ProcessWire installation, so we can suggest how to store information about them. 2 Link to comment Share on other sites More sharing options...
dragan Posted May 9, 2018 Share Posted May 9, 2018 @hellboy PW users are also just pages. Edit the user template, and add your addtl. fields. These two threads should get you going: Link to comment Share on other sites More sharing options...
hellboy Posted May 9, 2018 Author Share Posted May 9, 2018 Uhm, yeah i noticed that there is a module for shopping cart. But i want do it on my own :). I dont get it right now to use a button and store a new field to the logged in user. I hava a button like this: echo "<a class='cart-btn' href='#' >$shopingcard_text</a>"; so now i want to store the data from the form in custom user fields: echo "<form>"; <ul> <li> <div>Menge</div> <div class="count-input"> <div class="incr-btn" id="decr-btn" data-action="decrease"><i class="icofont icofont-curved-left"></i></div> <input class="quantity" type="text" name="quantity" value="1"/> <div class="incr-btn" id="incr-btn" data-action="increase"><i class="icofont icofont-curved-right"></i></div> </div> </li> <li id="price-amount" style="display: none"> <div>Gesamtpreis:</div> <div class="count-input" id="price-sum">2</div> </li> per javascript i add some more divs with price and productnumber. Link to comment Share on other sites More sharing options...
wbmnfktr Posted May 9, 2018 Share Posted May 9, 2018 How do you want to handle the whole shopping-cart-experience? Are you using Angular (or similar frameworks and tools) or do you want to handle everything with and within ProcessWire and PHP? Do you already have all the necessary business logic? Have you outlined a data model? Link to comment Share on other sites More sharing options...
hellboy Posted May 9, 2018 Author Share Posted May 9, 2018 Hiho, not a framework because its only for logged in users and they dont get charged by submitting the order is only a email that going to the company and customer. For that i dont want a framework because everything so far is good enough for pw. I dont want to make a big webapplication because its not necessary. Datamodel is a json right now to handle dropdown fields via ajax 50 - 100: {price: 225, productnumber: "900 01 050"}80 - 150: {price: 249, productnumber: "900 01 051"}120 - 200: {price: 255, productnumber: "900 01 052"} the bussiness logic is not implemented yet i want to store it in custom user fields and put a prefix on to delete it when the email is send to the client Link to comment Share on other sites More sharing options...
Ivan Gretsky Posted May 9, 2018 Share Posted May 9, 2018 I am still confused where you at and what you are trying to achieve: The form is on a product page and you want to store the selected number of products to display in the cart later. The form is at the end of a checkout process and you need to make a new order ...something else, like my 1st assumption. But let's think you know what you are doing and you want to save shopping cart contents (one or many product, quantity and price) to database and make that connected to the user currently logged in. You need to decide, where are you going to store that data in PW, choose a fieldtype for that. It can be a Repeater, ProFields Table or some specially crafted custom fieldtype. Those all fit as the are capable of storing random number of defined data (product, quantity and price). Them you need to create s field based on that fieldtype and configure it. Than add it to desired template. Depending on your case you could add that field directly to user template. But much more likely you need to create a new template (probably, "order" or something like that) and add this field there. On form submission you would use PW API to get the data from the user $input and save it in the created field on use page or order page. How to do that depend on the chosen field and template it was added to. Explain the case better please. 1 Link to comment Share on other sites More sharing options...
Ivan Gretsky Posted May 9, 2018 Share Posted May 9, 2018 5 minutes ago, hellboy said: the bussiness logic is not implemented yet i want to store it in custom user fields and put a prefix on to delete it when the email is send to the client Seems like you just want to email the contents of the cart. You probably do not even need to store the data, just send it right away like this or with FormBuilder (which seems like handy thing for you anyway). Link to comment Share on other sites More sharing options...
hellboy Posted May 9, 2018 Author Share Posted May 9, 2018 Ok sorry for the poor explanation. I have a site there you can go to a site and choose your product and click on a button "in Shopping-cart". What i want is now to retreive the submit from the button and store it in a field. When its there i can create the shopping cart view and list all the products that in the user fields a example is here http://ims.thomas-berendt.de/zubehoer/absperrblasen/kegelrohrdichtkissen/ Link to comment Share on other sites More sharing options...
wbmnfktr Posted May 9, 2018 Share Posted May 9, 2018 I wouldn't write those cart items to ProcessWire in first place. I'd store everything in a cookie so I can work with the data everywhere on the page. When the user is done - either in the cart itself or on a checkout page - I would render a list with all the items and relevant details and actions. The last step - sending the details to whoever - can be done via mail or FormBuilder or a custom form. Just as @Ivan Gretsky already mentioned. At that very moment when everything is done or about to be completed you could also save a dump of your cookie/cart/mail to ProcessWire. Link to comment Share on other sites More sharing options...
hellboy Posted May 9, 2018 Author Share Posted May 9, 2018 ah ok yeah thats was my first aproach but i dont find a proper way to save the thing in coockies? Link to comment Share on other sites More sharing options...
wbmnfktr Posted May 9, 2018 Share Posted May 9, 2018 A proper way to write cookies... JavaScript. An easy way to write and manage cookies... https://github.com/js-cookie/js-cookie Link to comment Share on other sites More sharing options...
hellboy Posted May 9, 2018 Author Share Posted May 9, 2018 ah perfect thats awesome thank you!!! im trying to implement that this week. thank you all Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now