Jump to content

Shop-for-ProcessWire (@Apeisa)


Nico Knoll

Recommended Posts

Hello,

I try find a solution how can, after click 'Place your order' the customer received an email with the order details.

For testing i'm trying adding some code like this in the PaymentInvoice.module

...

$pay = $modules->get("ShoppingCheckout")->renderConfirmation();

echo $pay;

...

(If this solved, I putting the variable '$pay' in a mail()-function.)

But this gives a server error.

What do I wrong  ???

I spent hours, but with no luck  :'(  :'(  :'(

Who can help me find a solution for this???

Christophe

Link to comment
Share on other sites

Ok,

I try the PaymentExample.module

This renders the order details in a variable '$out'

1. I don't want display it at the PaymentExample.module, only mail this order details.

How can I do this?

<?php

require_once(dirname(__FILE__) . '/PaymentAbstract.php');

class PaymentExample extends PaymentAbstract {
	
    public static function getModuleInfo()
	{
		return array(
			'title' => 'Betaalmogelijkheden',
			'version' => 001,
			'summary' => 'Betaalmogelijkheden',
			'singular' => false,
			'autoload' => false
		);
	}
    public function init() {
		$this->title = $this->_("Bancontact");
	}
	
	/*
	 *
	 * returns nothing. You should edit and save $order page. If payment was succesful,
	 * then do $order->removeStatus(Page::statusUnpublished) and remember to save the order!
	 *
	 * If order was also paid, then do $order->sc_paid = time();
	 *
	 * If order was not paid, but it was succesful (like invoice, money on delivery etc)
	 * then just publish the order, but do not set sc_paid value.
	 *
	 * After you have manipulated the order, then just to redirect to $this->completedUrl
	 *
	 *
	 * @param Page $order keeps the page object for the order
	 *
	 */
    public function processPayment(Page $order) {
		if ($this->input->get->ok) {
			
			if ($this->input->get->ok == 'fail') {
				// We don't remove statusUnpublished. That means failed or cancelled payment
				$this->session->redirect($this->completedUrl);
			}
			
			if ($this->input->get->ok == 'paid') {
				$order->setOutputFormatting(false);
				$order->sc_paid = time();
			}
			
			$order->removeStatus(Page::statusUnpublished);
			$order->save();
			
			$this->session->redirect($this->completedUrl);
			
			
		}
		
		//  No need to really do anything like this on payment module, this is here just for educational purposes):
		$out = "<h2>Products ordered</h2>";
		
		$out .=	"<ul>";	
		// Products
		foreach($order->children('check_access=0') as $p) {
			$out .= "<li><strong>{$p->title}</strong> {$p->sc_price}€ x {$p->sc_qty} (total: ". $p->sc_qty * $p->sc_price ."€)</li>";
		}
		$out .= "</ul>";
		
		$out .= "<h2>Shipping details</h2>";
		
		$out .=	"<ul>";	
		$out .= "<li>First name: $order->sc_firstname</li>";
		$out .= "<li>Last name: $order->sc_lastname</li>";
		$out .= "<li>Email: $order->email</li>";
		$out .= "<li>Street address: $order->sc_streetaddress</li>";
		$out .= "<li>Zip: $order->sc_zip</li>";
		$out .= "<li>City: $order->sc_city</li>";
		$out .= "<li>Country: $order->sc_country</li>";
		$out .= "<li>Username: {$order->sc_customer->name}</li>";
		$out .= "<li>Email address from user: {$order->sc_customer->email}</li>";
		$out .= "</ul>";
		
		$out .= "<h2>Other interesting stuff</h2>";
		$out .= "<ul>";
		$out .= "<li>Current url: {$this->currentUrl}</li>";
		$out .= "<li>Completed url: {$this->completedUrl}</li>";
		$out .= "</ul>";
		
		// Usually we would use some payment api or send people to 3rd party service like paypal
		// and process their reply
		
		$out .= "<h3>How do we proceed?</h3>";
		
		$out .= "<ul><li><a href='./?ok=invoice'>Send me an invoice</a>";
		$out .= "<li><a href='./?ok=paid'>I pay this with Magic Money™</a>";
		$out .= "<li><a href='./?ok=fail'>I want to fail this payment</a>";
		
		return $out;
    }
}

PS: When I rename this module by example: PaymentVisa.module then it is disappeared from the payment options menu in the checkout  ???

Christophe

Link to comment
Share on other sites

  • 1 month later...

Does the Shopping Cart module support shipping costs per item? There appears to be a fixed price options but my client wants to have the shipping calculated per item (I have suggested several times to put the shipping cost on the item and promote it as "free shipping" but they seem to be uninterested in this). It there a method of calculating postage?

EDIT: I figured it out, I needed to create a module to handle the shipping calculations.

Link to comment
Share on other sites

  • 2 weeks later...

I'm just evaluating this shopping module.

Using the following code to show number of product in cart. However, it just simply show a plain numeric digit on the page.

echo $modules->get('ShoppingCart')->getNumberOfItems(false);

How to display more information, like in a list of

product title, product quality

Link to comment
Share on other sites

  • 4 weeks later...

Hi,

hopefully you can give me some advice on debugging an error with a ProcessWire 2.5 site using ShoppingCart module (and Version Control module):

When guest users try to add a specific product to the shopping cart, a "500 Internal Server Error" page is thrown and the following error is logged in assets/logs/errors.txt:

2015-05-25 18:28:06     guest   http://127.0.0.1/pw/product-12      Error:  Exception: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '01, session_id = 'd41a2726a1f1d8205f45ce240da65af10517c74f' ON DUPLICATE KEY UPD' at line 1 (in /var/www/pw/wire/core/Database.php line 114)

Since only a part of the SQL error is shown, I have difficulties to find out what's wrong here.

The error does only occur with two products (a hundred others are fine) and only with guest users. If I add these products as a logged in admin, everything works great.

The database tables do not include a session ID d41a2726a1f1d8205f45ce240da65af10517c74f. How do I get a more specific error message from ProcessWire?

Thanks

Sarah

Link to comment
Share on other sites

This needs to be moved to the "modules" forum: It definitely is a shoppingCart problem.

The complete database query is:

 INSERT INTO ShoppingCart SET items = '[{"product_id":3124,"qty":1}]', total_sum = 10,50, session_id = 'e3bc4bb75fa765aefc4695fa27820f1464f39fb3' ON DUPLICATE KEY UPDATE items = '[{"product_id":3124,"qty":1}]', total_sum = 10,50 

From my point of view the problem seems to be the comma separated price used for the query. While the sc_price field contains "10.50" (with a dot as decimal mark), for unknown reasons a comma is used as a result for this query line ShoppingCart.module:

		// Update cart to db or insert new row if there isn't
		$update = $this->db->query("INSERT INTO {$this->className} SET items = '$items', total_sum = $total_sum, session_id = '" . $this->getSession() . "' ON DUPLICATE KEY UPDATE items = '$items', total_sum = $total_sum");

My module settings define a comma as decimal mark:

post-3026-0-37890100-1432813948_thumb.pn

Though this comma should not be used unless it is produced via $this->renderPrice($total_sum).

No explanation/solution so far.

Link to comment
Share on other sites

  • 4 weeks later...

I'm stuck here

how do i call a field from the page into the module ShoppingCheckout

i want to have extra text fields in every step of the checkout process that can be filled in in the back-end.

thanks,

ANK

Link to comment
Share on other sites

  • 4 months later...

Hi, I've got Shop-for-processWire up and running on a site and everything's working beautifully.

I now need to be able to send a confirmation email to the buyer from the 'Thank you' page.

I'm trying to get the order info from the order page via $session->orderId, and although many of the entries (price, address, shipping method etc) are populated, sc_product and sc_qty are empty.

Does anyone know how I'd go about including these?

Thanks,
Paul

Link to comment
Share on other sites

Hi, I've got a problem when text entered in the 'Other Information' text area field includes a single quote. Rather than just the quote being removed, the remainder of the text is removed with it.

As a test, I tried commenting out the sanitzer line in validateInformation(), but the quote and all following text was still removed.

It's pretty much guaranteed that users will frequently use apostrophes here, and vital delivery information could be lost if the text gets mangled.

Thanks for any ideas,

Paul

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...