Jump to content

Shop-for-ProcessWire adding extra fields


Ronnie
 Share

Recommended Posts

Hello.
I have been using PW as a CMS for some Projects in the past, now the questions regarding ecommerce i starting to pop up.
It would be nice to be able to operate both the site and the shop from PW, somewhat like WP + WP e-Commerce, but i rather stick to PW.
 
Anyway I have started to look at the module Shop-for-Processwire and right off the bat there are som questions.
1. Have anybody added extra fields / values that the process carrys from the Product page to the checkout module and finally in the orders management module, i am thinking of Product variations like color size etc.
If i just look at the module i guess a stating pont would be to get the form populated with thoose extra variations.
 

  $out = "<form method='post' action='$postUrl'>";
  $out .= "<input type='hidden' value='{$product->id}' name='sc_product_id' />";
  $out .= "<input type='number' name='sc_qty' value='1'/>";
  $out .= "<input type='text' name='sc_size' value='S'/>";
  $out .= "<input type='submit' value='" . $this->_("Add to cart") . "' />";
  $out .= "</form>";

Once extra input types has been added how can I get thoose through the whole process, Product - >Checkout -> Orders Management.

2. Do I have to add extra tables to the db to be able to store this information ?

3. I have read on the forum that some of you have handled variations by using repeaters and page fields, is there anybody out there that have a working example regarding that ?

Help would be much appretiated, would hate to be crawling back to WP..

Thanks / Ronnie



Code line 92

  $out .= "<input type='text' name='sc_size' value='S'/>";

Has been added by me as a example.

Link to comment
Share on other sites

I just committed the support for variations (using repeaters):

  • create a repeater which has title and sc_price fields
  • add it to your product template
  • loop your variations on product page (you can have product without variations too)

Here is example code for looping the variations (or using fixed price). Repeater is called shop_product_variations:

$sc = $modules->get("ShoppingCart");
	if ($page->shop_product_variations->count() > 0) {
		$page->body .= "<p>Choose variation:</p>";
		$page->body .= "<div class='variations'><form method='post' action='./'><table>";
		foreach ($page->shop_product_variations as $p) {
			$page->body .= "<tr><td><input type='radio' value='{$p->id}' id='sc_product_id_{$p->id}' name='sc_product_id' /><label for='sc_product_id_{$p->id}'>{$p->title}</label></td><td class='price'>". $sc->renderPrice($p->sc_price) ."</td></tr>";
		}
		$page->body .= "</table><input type='number' class='sc_qty' name='sc_qty' value='1'/> a <input type='submit' value='Add to Cart' /></form></div>";
	} else {
		$page->body .= "<div class='price'>Price: ". $sc->renderPrice($page->sc_price) . "</div>";
		$page->body .= "<form method='post' action='./'><input type='hidden' value='{$page->id}' name='sc_product_id' /><label for='sc_qty'>Qty</label><input type='number' class='sc_qty' name='sc_qty' value='1'/> <input type='submit' value='Add to Cart' /></form>";
	}	


And example of variations on live site: http://www.martanpuoti.fi/tuotteet/mennaan-eika-meinata-t-paita-unisex/muut-tuotteet/

  • Like 2
Link to comment
Share on other sites

Thanks nice work, you are such a boss. 

Nice website as well.

I have fiddled around with the new features, I tried to have the options as a drop down-list instead but it didn't work, I am suspecting is has to do with the label field for the input type.

<label for='sc_product_id_{$p->id}'>{$p->title}</label>

Is it this one that is being processed and appended to the product title ? 

Would it be possible to edit the module so it could append other values as well and perhaps different values.

What I am aiming for is for example two drop down lists for a specific product, each drop down fetches information from its own repeater.

Repeater 1 say Color: has values of ex white, brown, yellow.

Repeater 2 say Size: has values of ex S, L, M

If I am only able to use one repeater and I have 4 sizes and 4 colors i would end up with 16 choices for each product witch would be quite a lot.

I hope that you are able to understand what I am trying to achieve.

I assume this would be possible but I am not able to figure it out...grateful for assistance

Thanks / Ronnie

Link to comment
Share on other sites

  • 1 month later...

Bit late to the party, but there is actually some merit to keeping different colours as separate products anyway.

It's a tricky call on some websites, but if you keep them separated by colour, the customer can see all colours when browsing a product category, otherwise there is actually a chance they will see a blue t-shirt for example and not click through because they wanted a red one, even though it is an option if only they had clicked through.

Of course if you're selling hundreds of products with many variations this could become messy, but it also allows you to do things like sort by colour easily and have a search list of all red shirts for example with pictures in a list or grid.

The problem with variations where you get a bit more complicated with a size and a colour is that you ideally want to be able to manage them easily (and the list can get long!) but also be able to easily turn certain colours and sizes off (it happens occasionally that there might not be an XXL manufactured in green but there is in every other colour). This sort of thing usually results in a reasonably complex variation grid that I couldn't begin to think how to best code, but I know that as an occasional end user it is actually easier on my brain to separate out by colour rather than manage a large list of different combinations of variations.

Just my thoughts :)

Link to comment
Share on other sites

  • 5 months later...

Hello Everyone. 

I am using PW shop module and have question in the same direction as the above post. Currently when shopping cart is showing product name, quantity, price. How can I show a Part ID field to the cart and to paypal when it interacts. 

Any advice would be great, I am 96% not a programmer :)

Thanks

Teja

Link to comment
Share on other sites

  • 1 month later...

I´m handling variations with child items at the moment but I think will change it to repeaters because only a few products will have variations as I know now so it would be a little overhead

ProcessWire is really awesome! It´s kind of fun changing structure while developing and note handling it a little different would be more logic

Link to comment
Share on other sites

Repeaters are also pages in the back. But for such a thing like variations its perfect fit as it's a page with an actual id. That makes the system handling variations easier as its just like a product. I always handled simple variations by making a single product also be a variation. So products would always be a repeater. But you can also have both mixed with the shop module.

Link to comment
Share on other sites

aha interesting..having even a single product as variation..

I´m trying to figure out which way I like more  :)

either no repeater for no variations or the way you described it..thanks for the hint

I guess child pages could be great for larger variations where they each have images etc..

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...