Jump to content

Shop-for-ProcessWire (@Apeisa)


Nico Knoll

Recommended Posts

Adde a couple commits with a PR to Shop Module with some small fixes and additions:

https://github.com/apeisa/Shop-for-ProcessWire/pull/8

- added support for variation price, so you can have price per variation. Cart will look for it and use the price in repeater item, else it will take the one from page

- added 2 new methods to cart module:

getProductPrice($item) will return product price from either repeater or product page

getProductPriceTotal($item) will return product price total for quantity in $item->qty

- made those methods bookable also so they could be modified maybe useful for discounts etc.

- updated checkout module for this new price calculation

I'm working on a simple shop currently for the 4-5 time now and taking the shop module always a little further on the way.

Thanks

  • Like 5
Link to comment
Share on other sites

While using the shop module, here a thought that come to mind every time.

I would like to see that the forms output by the checkout being ProcessWire forms generated via API. This would allow to modularize/extend this part much easier. Currently it's just html markup concatenated together and it makes it impossible to modify it without modifying the module. Another option would be to make methods that are generating the markup hookable, but I'd rather like PW form API fields. This would also allow for easier rendering and validating the form.

What you think?

  • Like 1
Link to comment
Share on other sites

Thanks for the PR soma! I think those are good to go. Although I think price support in repeaters/variations probably mean that I need to update my payment modules to support that instead of direct price.

Agreed about using API to generate markup.



Actually, now when thinking about it more, payments should be ok already, since they are using order-items instead of products, so you have taken care of that already.

  • Like 2
Link to comment
Share on other sites

I'm currently creating an additional shopping module type for simple discount calculation in the cart.

The idea is as soon as you install this module, shopping cart is recognizing it and adds it into calculation and outputs it in the cart.

The module work like the shipping cost module, but will only be needed once, so no abstract class is needed. You then can enter percent of the discount and the threshold.

I need this for a current simple shop I'm building. In the past I never needed that and on first shop I built I did this by building a custom checkout.

Do you think this is a good idea? Or would it be better to modularize these things more in cart/checkout so one could add them without the need to modify "core" shop modules?

  • Like 1
Link to comment
Share on other sites

I'm currently creating an additional shopping module type for simple discount calculation in the cart.

The idea is as soon as you install this module, shopping cart is recognizing it and adds it into calculation and outputs it in the cart.

The module work like the shipping cost module, but will only be needed once, so no abstract class is needed. You then can enter percent of the discount and the threshold.

I need this for a current simple shop I'm building. In the past I never needed that and on first shop I built I did this by building a custom checkout.

Do you think this is a good idea? Or would it be better to modularize these things more in cart/checkout so one could add them without the need to modify "core" shop modules?

Here's some inspiration on discount rules: http://doc.prestashop.com/display/PS15/Creating+Price+Rules+and+Vouchers

Link to comment
Share on other sites

Thanks Beluga. 

This is just a simple discount feature and nothing to do with vouchers or anything complicated. Just a simple calculation.

Thing is that most simple shops I build are only local shops and most have discount depending on total sum. So I need that feature, that's why I'm working on it. I have no plans to make a full featured thing.

Further here in Switzerland we're the only country in the world that has no 0.01 amount, smallest is 0.05! So I even need a special rounding. So far I have added just a method (hookable) just for that in the discount module or maybe it would even make more sense in cart module itself.

It's obvious there's many things to consider and not every shop is the same, so at least a little flexibility is helpful here.

Link to comment
Share on other sites

<quote>Switzerland we're the only country in the world that has no 0.01 </quote>

The netherlands they don't accept cents in shops. always rounded, not floored.

( Must be a multiple of 10 years we payed with cents, I can't remember it )

But you don't accept, we don't even have it :) Well then there would be the hook for your needs ;)

Link to comment
Share on other sites

Just pushed a new dev branch to my fork of Shop module with the current version of the discount module included. Working nice so far.

https://github.com/somatonic/Shop-for-ProcessWire/tree/dev

https://github.com/somatonic/Shop-for-ProcessWire/commit/80663d3512ff251b0f616f812645b24573e19834

If anyone interested to try to see.

This is my how my cart looks:

post-100-0-25562500-1389365398_thumb.png

  • Like 7
Link to comment
Share on other sites

Here are my docs for the shop I've been building with PrestaShop:

presta-docs.zip

Using prism.js to highlight code and this wonderful js function to escape html entities I discovered at the last minute after worrying about this for over a month.

If he has time to review it, I'm interested in what Antti thinks about my Checkout.fi implementation (I'm still a newbie to stuff like this and serious development in general).

The docs show how PrestaShop users have to jump through all kinds of flaming hoops to bend the shop to their will.

I also have one open issue that you SQL wizards might know the answer to: in the PrestaShop SQL manager that does CSV exports, I'd like to be able to concatenate all the addresses of a single customer into one field, while this creates a new row for every address:

SELECT CONCAT_WS(' ', g.lastname, g.firstname) AS Customer, g.id_customer AS customerID, CONCAT_WS(' ', ad.address1, ad.address2, 'City:', ad.postcode, ad.city, ad.other, 'Phone:', ad.phone, 'Mobile:', ad.phone_mobile) AS Addresses, gl.name AS group_name, g.email
    FROM  ps_customer g
    LEFT JOIN ps_address ad ON (g.id_customer = ad.id_customer)
    LEFT JOIN ps_group_lang gl ON (g.id_default_group = gl.id_group) AND gl.name LIKE 'piiri%'
 
  • Like 1
Link to comment
Share on other sites

If I understand what what you're looking for exactly, you will probably want to make use of GROUP_CONCAT. I think something like this should work:
 

SELECT CONCAT_WS(' ', g.lastname, g.firstname) AS Customer, g.id_customer AS customerID, GROUP_CONCAT(CONCAT_WS(' ', ad.address1, ad.address2, 'City:', ad.postcode, ad.city, ad.other, 'Phone:', ad.phone, 'Mobile:', ad.phone_mobile)) AS Addresses, gl.name AS group_name, g.email
FROM ps_customer g
LEFT JOIN ps_address ad ON (g.id_customer = ad.id_customer)
LEFT JOIN ps_group_lang gl ON (g.id_default_group = gl.id_group) AND gl.name LIKE 'piiri%'
GROUP BY g.id_customer
 
  • Like 1
Link to comment
Share on other sites

If I understand what what you're looking for exactly, you will probably want to make use of GROUP_CONCAT. I think something like this should work:

SELECT CONCAT_WS(' ', g.lastname, g.firstname) AS Customer, g.id_customer AS customerID, GROUP_CONCAT(CONCAT_WS(' ', ad.address1, ad.address2, 'City:', ad.postcode, ad.city, ad.other, 'Phone:', ad.phone, 'Mobile:', ad.phone_mobile)) AS Addresses, gl.name AS group_name, g.email
FROM ps_customer g
LEFT JOIN ps_address ad ON (g.id_customer = ad.id_customer)
LEFT JOIN ps_group_lang gl ON (g.id_default_group = gl.id_group) AND gl.name LIKE 'piiri%'
GROUP BY g.id_customer
 

Thank you very much, it seems I have a hole in the head that leaks information :blink:

Link to comment
Share on other sites

  • 3 weeks later...

Hello

I am trying to build a webshop with processwire.

I am setting up Apeisa's Shop-for-processwire Module.

Normally you have to setup a folder under /site/modules

and give the folder the same name as the module name.

However there are 8 files inside the zipfile with the extension .module

so which one to chose ? One of the files is ShoppingCart.module

so I guess that must be the one and use the word ShoppingCart

for the folder name that I have to put inside the modules folder.

But I better ask to be sure.

Also I want to ask if I can use this module just for banktransfers

and not for paypal.

Is there an example processwire template that uses the shoppingcart ?

Thanks.

Link to comment
Share on other sites

Thanks Nico.

I found 2 templates here

http://processwire.com/talk/topic/550-e-commerce-with-processwire/page-9#entry27094
http://processwire.com/talk/topic/550-e-commerce-with-processwire/page-9#entry27097
 

I am going through these threads to learn more.

http://processwire.com/talk/topic/550-e-commerce-with-processwire/

http://processwire.com/talk/topic/1732-shop-for-processwire-apeisa/

You guys can read and write code on the fly, I can't so I need some head start.

If anyone knows another template or a pw profile for Apeisa's shop just let me know.

Link to comment
Share on other sites

Thanks Soma, I just did that and used the word "ShoppingCart" as the name for the folder under site/modules/.

Also I just saw that the latest pw dev has an extra button in the backend for automatically find new modules.

That all worked well.

I checked the readme but the beginners problems I have is setting up calls in a shop template.

This is a template I found from Dave. Is this really all you need to run a shop ? Sorry for asking must read

silly but like I said just beginning with apeisa's module and a pw shop.

<?php

/**
* Page template
*
*/


include("./head.inc");
include("./navbar.inc");
?>

<div class="container">
<h1>Your Cart</h1>
<?php echo $modules->get("ShoppingCart")->renderCart(); ?>
</div>

<?php
include
("./foot.inc");

  • Like 1
Link to comment
Share on other sites

Just looked back at that (abandoned) project.

The way I did it at the time was to have each product as a page (in an appropriate hierarchy), with fields like description, image and price, and show the add to cart button with

<?php echo $modules->get("ShoppingCart")->renderAddToCart(); ?>

As I recall, it all worked as expected.

<Edit>

Just tried it, and it still works.

Checkout page is quite like cart page  :rolleyes:

<?php

/**
 * Page template
 *
 */

include("./head.inc");
include("./navbar.inc");
?>
<div class="container">

<?php echo $modules->get("ShoppingStepsMarkup")->render(); ?>

<?php echo $modules->get("ShoppingCheckout")->renderCheckout(); ?>

</div>

<?php
include("./foot.inc");
Edited by DaveP
Link to comment
Share on other sites

  • 2 months later...

Hope this is the right place to post this...

I've installed Shopping Cart and the Fixed Cost Shipping module, but renderCart() isn't outputting the code in the 'if ($shippingModule) {' block. The FixedCostShoppingModule isn't listed in the 'Modules Loaded' section of the debug tools either. I tried changing the references to the module name to 'ShippingFixedCostModule' but that didn't work.

I have been able to pull the shipping price into a template using:

$modules->get('ShoppingCart')->getTotalSumFromItems($items, $modules->get('ShippingFixedCost'))

So that makes it seem like it is loaded, but I'd like the shipping added when I call renderCart.

Link to comment
Share on other sites

Not on computer now, but if I reckon right, shipping is not shown at that phase at all, just before confirmation. But if you have fixed shipping price, why not just render mention about it under your cart?

Link to comment
Share on other sites

There's two arguments to give renderCart()

If you only have one fixed shipping cost you could give it as the second argument, the first being true or false, viewonly or not editable cart.

https://github.com/apeisa/Shop-for-ProcessWire/blob/master/ShoppingCart.module#L193

echo $modules->ShoppingCart->renderCart(false, $modules->ShippingFixedCost);

The module isn't autoload, but loaded on demand.

Link to comment
Share on other sites

When i work on development server locally renderCart() and renderAddToCart() functions throw no errors and perfectly as they should.

Even when i install modules on server directly, they do work.

But when i develop locally and then port the project to a domain on server somewhere else on the internet , my functions throw up errors even though rest of processwire pages work fine.

Below is error thrown, where renderCart() function is called.On dev local system it shows 'No items in cart'

post-2174-0-80292200-1399234584_thumb.jp

This error occurs when clicked on add to cart :

post-2174-0-66049000-1399234582_thumb.jp

Pls help!!!

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...