Jump to content

Link to invoice on Order Confirmation Page for Guest Customer


Paldru

Recommended Posts

How can I get the link to the PDF invoice for unregistered Guest customers to appear on the order confirmation page?
(www.someshop.com/order-confirmation)


Similar to the link under www.someshop.com/guest-tracking ("Download your invoice as a PDF file.")?

How is the link to the PDF generated?


Thanks for your help.

Link to comment
Share on other sites

Looking at themes/default-bootstrap/order-detail.tpl, it's the following code that creates the link:

{$link->getPageLink('pdf-invoice', true)}?id_order={$order->id|intval}{if $is_guest}&secure_key={$order->secure_key|escape:'html':'UTF-8'}{/if}
Link to comment
Share on other sites

 

Looking at themes/default-bootstrap/order-detail.tpl, it's the following code that creates the link:

{$link->getPageLink('pdf-invoice', true)}?id_order={$order->id|intval}{if $is_guest}&secure_key={$order->secure_key|escape:'html':'UTF-8'}{/if}

 

The problem with it when used e.g. in modules/bankwire/views/templates/hook/payment_return.tpl, is that the secure key and order number are missing.

I would need to know how to get the secure key working.

As a work around I use JavaScript to generate a new url - since the url shown in the browser when on order confirmation page uses a key (and it is the same as the secure_key), I copy the key and add it to the pdf link url and it works. So instead of:

 

"someshop.com/en/index.php?controller=pdf-invoice?id_order=0&secure_key=" 

 

I have something like:

 

"someshop.com/en/index.php?controller=pdf-invoice?id_order=1&secure_key=1c7b7efb973da769b4dc330b7fec923b"

 

 

But I would rather have a proper solution.

Edited by Paldru (see edit history)
Link to comment
Share on other sites

Reading the Bankwire module code that calls payment_return, it seems {$id_order} does exist, but {$secure_token} doesn't:

	public function hookPaymentReturn($params)
	{
		if (!$this->active)
			return;

		$state = $params['objOrder']->getCurrentState();
		if (in_array($state, array(Configuration::get('PS_OS_BANKWIRE'), Configuration::get('PS_OS_OUTOFSTOCK'), Configuration::get('PS_OS_OUTOFSTOCK_UNPAID'))))
		{
			$this->smarty->assign(array(
				'total_to_pay' => Tools::displayPrice($params['total_to_pay'], $params['currencyObj'], false),
				'bankwireDetails' => Tools::nl2br($this->details),
				'bankwireAddress' => Tools::nl2br($this->address),
				'bankwireOwner' => $this->owner,
				'status' => 'ok',
				'id_order' => $params['objOrder']->id
			));
			if (isset($params['objOrder']->reference) && !empty($params['objOrder']->reference))
				$this->smarty->assign('reference', $params['objOrder']->reference);
		}
		else
			$this->smarty->assign('status', 'failed');
		return $this->display(__FILE__, 'payment_return.tpl');
	}

Try changing the id_order line above to:

                                'id_order' => $params['objOrder']->id,
                                'secure_key' => $params['objOrder']->secure_key

Then you can use {$id_order} and {$secure_key} in payment_return.tpl.

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