Jump to content

which hook for after check out / confirm page


vik*

Recommended Posts

I would like to place my plugin on on the confirm page, when user ordered products. Which hook can I use? Any examples?

 

I get all product data from the cart object.

$cart->getProducts(true);

 

Is there a way to get all the ordered products from an order? And I also would like to have some user data, like the email of the user.

 

Examples would be a great help. Thank you!

Link to comment
Share on other sites

you want to hook orderConfirmation. You see the following function in a lot of payment modules.

 

$params['objOrder'] is the actual Order object. You can use that to access anything about the order (products, customer etc..)

 

	public function hookOrderConfirmation($params)
{
	global $smarty;

	if ($params['objOrder']->module != $this->name)
		return;

	if ($params['objOrder']->getCurrentState() != Configuration::get('PS_OS_ERROR'))
		$smarty->assign(array('status' => 'ok', 'id_order' => intval($params['objOrder']->id)));
	else
		$smarty->assign('status', 'failed');

	return $this->display(__FILE__, 'hookorderconfirmation.tpl');
}

Link to comment
Share on other sites

Bellini - could you express it a little more clear to me?

 

After payment (using danish gateway), my users get to a page, designed by the module maker and in that tpl file i have:

{$HOOK_ORDER_CONFIRMATION}

 

what should i do, to show a mesage to the user along wit eventually a order detail.

 

I tried to add an include file order-detail.tpl, but that doesnt work....

 

Any ideas?

 

Happy new year

Link to comment
Share on other sites

can you send me the payment gateway module that you are referring to, you can send it via a PM. the payment module can hook orderConfirmation, if it's not already, but it assumes the module redirects to order confirmation page correctly.

 

so let me take a look at how it was implemented, and then I can advise you better.

Link to comment
Share on other sites

in the quickpay module, there is a file complete.tpl. You can update that file to include a different message to the borrower.

 

Also instead of putting the order detail in the confirmation page, I would just include a link to the actual order history, let them click on the link.

Link to comment
Share on other sites

there are some changes required to complete.php and complete.tpl to get the email. since you are altering a template file, you will need to enable force compile after making these changes.

 

1) update complete.php to get the customer and place the email address in the smarty engine.

 

this line will create the customer object. place this around line 20, just before the $smarty->assign line

$customer = new Customer((int)($order->id_customer));

then update the smarty assignment to include the email address

$smarty->assign(array(
  'order' => $id_order,
  'email' => $customer->email,
  'HOOK_ORDER_CONFIRMATION' => Hook::orderConfirmation(intval($id_order)),
  ));

 

2) update the complete.tpl (template) to display it.

All you need to do is place {$email} where you want the email address to display. So you could do something like...

Your email address is {$email}

Link to comment
Share on other sites

Bellini - You are my life saver. It works perfectly.

I know im asking a lot here - and just let me know, if this requieres payed help, ok?

 

Is it possible on that page, to allow that costumer to either view or download the invoice?

 

I ask, because i dont use / allow people to register on the page and therfore, they cant see or use history.php

 

Best regards,

Kristian

Link to comment
Share on other sites

The first thing pdf-invoice.php does is check if the user is logged in. What customizations have you made that prevent this?

 

if (!$cookie->isLogged() AND !Tools::getValue('secure_key'))
   Tools::redirect('authentication.php?back=pdf-invoice.php');

If you have done some type of customization, then you will need to create a custom pdf-invoice.php file that removes those authentication checks, but I would highly advise not doing that, since anyone will be able to view any invoice.

Link to comment
Share on other sites

include(dirname(__FILE__).'/config/config.inc.php');
include(dirname(__FILE__).'/init.php');
$cookie = new Cookie('ps');
if (!$cookie->isLogged() AND !Tools::getValue('secure_key'))
Tools::redirect('authentication.php?back=pdf-invoice.php');
if (!(int)(Configuration::get('PS_INVOICE')))
die(Tools::displayError('Invoices are disabled in this shop.'));
if (isset($_GET['id_order']) AND Validate::isUnsignedId($_GET['id_order']))
$order = new Order((int)($_GET['id_order']));
if (!isset($order) OR !Validate::isLoadedObject($order))
   die(Tools::displayError('Invoice not found'));
elseif ((isset($cookie->id_customer) AND $order->id_customer != $cookie->id_customer) OR (Tools::isSubmit('secure_key') AND $order->secure_key != Tools::getValue('secure_key')))
   die(Tools::displayError('Invoice not found'));
elseif (!OrderState::invoiceAvailable($order->getCurrentState()) AND !$order->invoice_number)
die(Tools::displayError('No invoice available'));
else
PDF::invoice($order);

 

That is what my pdf-invoice.php looks like.

 

I havent done any customization to that file.

Link to comment
Share on other sites

understood, but apparently you have made other customizations to your shop, which is preventing the pdf invoice from working properly.

 

previously you said ...

I ask, because i dont use / allow people to register on the page and therfore, they cant see or use history.php

 

how do you accomplish that?

Link to comment
Share on other sites

I see what you mean.

 

The site in question is www.uni-media.dk/devsantoku

 

Im using 5 step checkout, modified, so there is no payment option(only creditcard) and no carrier selection, because im only using 1 carrier.

 

i only use the shoppin-cart - authentication - popup payment window - and at the end you get the complete.tpl file from the payment gateway :-)

 

Hope that made sense.

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
×
×
  • Create New...