rusjoan Posted October 13, 2013 Share Posted October 13, 2013 Hi everyone! I need your help in one interesting question. I'm creating now my own internet shop on Processwire engine. And this shop will contain different types of goods. For example, t-shirts, mugs, stickers, etc. And I should give some options of goods to my customers. Customer can select different sizes of t-shirts, different colors of stickers, different image (print) of mugs. And how to do this option differentiation of type of goods on the PW? Is there any solution except that I should create specific templates for specific goods? Sorry for my english, but I hope you have understood me Link to comment Share on other sites More sharing options...
Pete Posted October 13, 2013 Share Posted October 13, 2013 I think different templates is a good option here. If you create the basic "product" template, you can then go to edit it, click the Advanced tab and use the Duplicate/Clone option to copy it, then add the additional fields you require. 1 Link to comment Share on other sites More sharing options...
rusjoan Posted October 13, 2013 Author Share Posted October 13, 2013 OK, I'll try it. Any suggestions? Link to comment Share on other sites More sharing options...
ryan Posted October 19, 2013 Share Posted October 19, 2013 I agree with Pete that it'd be good to use different templates for your different types of products, as this fits the definition of a template. But if this is going to lead you to creating dozens of very similar templates, then I'd be less enthusiastic about that. If that's the case you may want to delegate your product options to a tree of page references (using PageListSelectMultiple inputfield maybe). If the options are very simple, you could always just identify them with each product in a textarea field (one per line). Textarea fields can be quite useful, as you can explode("\n", $page->textareaField) to convert it to an array and generate select options/radio buttons, etc. But you'd only take this path if the options were generally unique per product. 1 Link to comment Share on other sites More sharing options...
rusjoan Posted October 19, 2013 Author Share Posted October 19, 2013 OK, thanks. Can you say how I can organize unregistered customer cart where different types of templates have place? Maybe it'd good to create new cart in "Carts" branch and place here all of that customer will choose? (Each cart will have PageListSelectMultiple inputfield) Link to comment Share on other sites More sharing options...
ryan Posted October 23, 2013 Share Posted October 23, 2013 I'm confused, why are carts pages? The way I usually think of carts is something that would be a session variable specific to a user browsing your site, not a permanent fixture in your page tree. I'm not sure storing user carts in this way would be a sustainable. Carts are something that you'd usually want to store in a session or cookie, and not convert it to any permanent server-side storage until it's a completed order that you have to fulfill. 1 Link to comment Share on other sites More sharing options...
rusjoan Posted April 12, 2014 Author Share Posted April 12, 2014 I'm confused, why are carts pages? The way I usually think of carts is something that would be a session variable specific to a user browsing your site, not a permanent fixture in your page tree. I'm not sure storing user carts in this way would be a sustainable. Carts are something that you'd usually want to store in a session or cookie, and not convert it to any permanent server-side storage until it's a completed order that you have to fulfill. OK, I'm agree with you, moreover I used this technique all time. Otherwise if internet-shop provide using online-constructors there is a real trouble to store all of user constructed data in sessions or cookie variables. The trouble itself is on we should to choose format to store data from different types of constructors. And then when user makes order, this data would be transformed to pages-form in PW DB. Is there a way to convert pages into session-storable variables? Wish there a way to convert page into assoc array and then json_encode it. Link to comment Share on other sites More sharing options...
teppo Posted April 13, 2014 Share Posted April 13, 2014 @rusjoan: for converting content of a page to JSON, you could do something like this: $data = array(); foreach ($page->template->fields as $field) $data[$field->name] = (string) $page->$field; $json = json_encode($data); Of course this isn't a complete solution and won't work in anything but the most limited use cases (think about images, files, page references etc.) but it's a start. 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