From ee0abc4f969307a8f05ef727e32b6e45b40240b0 Mon Sep 17 00:00:00 2001 From: Adrien B Date: Thu, 16 May 2019 14:20:02 +0200 Subject: [PATCH] feat: better receip page --- modules/btcpay/btcpay.php | 36 ++++ .../templates/customer/order-detail.tpl | 192 ++++++++++++++++++ 2 files changed, 228 insertions(+) create mode 100644 modules/btcpay/themes/pf_strollik/templates/customer/order-detail.tpl diff --git a/modules/btcpay/btcpay.php b/modules/btcpay/btcpay.php index af52e6b..f0b17df 100644 --- a/modules/btcpay/btcpay.php +++ b/modules/btcpay/btcpay.php @@ -32,6 +32,7 @@ // made for prestashop 1.7 use PrestaShop\PrestaShop\Core\Payment\PaymentOption; +use PrestaShop\PrestaShop\Adapter\Presenter\Order\OrderPresenter; if (!defined('_PS_VERSION_')) { exit; @@ -90,6 +91,9 @@ public function __construct() { $this->description = $this->l('Accepts Bitcoin payments via BTCPay.'); $this->confirmUninstall = $this->l('Are you sure you want to delete your details?'); + $this->registerHook('displayOrderDetail'); + $this->registerHook('displayBackOfficeOrderActions'); + } public function install() { @@ -173,6 +177,14 @@ public function install() { } public function uninstall() { + + $this->unregisterHook('displayOrderDetail'); + $this->unregisterHook('displayBackOfficeOrderActions'); + $this->unregisterHook('invoice'); + $this->unregisterHook('paymentReturn'); + // prestashop 1.7 + $this->unregisterHook('paymentOptions'); + Configuration::deleteByName('btcpay_ORDERMODE'); Configuration::deleteByName('btcpay_TXSPEED'); Configuration::deleteByName('btcpay_TOKEN'); @@ -190,6 +202,30 @@ public function uninstall() { return parent::uninstall(); } + public function hookDisplayBackOfficeOrderActions($params) } + $btc_invoice = $this->get_order_field($params['cart']->id, 'redirect'); + if ($btc_invoice) } + //$this->context->smarty->assign('btc_invoice', $btc_invoice); + return '  +  '. + $this->l('Crypto Invoice') + .''; + } else } + return ''; + } + } + + public function hookDisplayOrderDetail($order) } + if ( $order['order']->module == $this->name ) } + $cart_id = Cart::getCartIdByOrderId($order['order']->id); + $btc_invoice = $this->get_order_field($cart_id, 'redirect'); + if ($btc_invoice) } + $this->context->smarty->assign('btc_invoice', $btc_invoice); + } + } + return ''; + } + public function getContent() { $this->_html .= '

'.$this->l('btcpay').'

'; diff --git a/modules/btcpay/themes/pf_strollik/templates/customer/order-detail.tpl b/modules/btcpay/themes/pf_strollik/templates/customer/order-detail.tpl new file mode 100644 index 0000000..5b45e0a --- /dev/null +++ b/modules/btcpay/themes/pf_strollik/templates/customer/order-detail.tpl @@ -0,0 +1,192 @@ +{extends file='customer/page.tpl'} + +{block name='page_title'} + {l s='Order details' d='Shop.Theme.Customeraccount'} +{/block} + +{block name='page_content'} + {block name='order_infos'} +
+
+
+
+ + {l + s='Order Reference %reference% - placed on %date%' + d='Shop.Theme.Customeraccount' + sprintf=['%reference%' => $order.details.reference, '%date%' => $order.details.order_date] + } + +
+ {if $order.details.reorder_url} + + {/if} +
+
+
+ +
+
    +
  • {l s='Carrier' d='Shop.Theme.Checkout'} {$order.carrier.name}
  • +
  • {l s='Payment method' d='Shop.Theme.Checkout'} {$order.details.payment}
  • + {if $order.details.payment == 'BTCPay'} +
  • {l s='Crypto Invoice' d='Shop.Theme.Checkout'} {l s='Open' d='Shop.Theme.Checkout'}
  • + {/if} + + {if $order.details.invoice_url} +
  • + + {l s='Download your invoice as a PDF file.' d='Shop.Theme.Customeraccount'} + +
  • + {/if} + + {if $order.details.recyclable} +
  • + {l s='You have given permission to receive your order in recycled packaging.' d='Shop.Theme.Customeraccount'} +
  • + {/if} + + {if $order.details.gift_message} +
  • {l s='You have requested gift wrapping for this order.' d='Shop.Theme.Customeraccount'}
  • +
  • {l s='Message' d='Shop.Theme.Customeraccount'} {$order.details.gift_message nofilter}
  • + {/if} +
+
+
+ {/block} + + {block name='order_history'} +
+

{l s='Follow your order\'s status step-by-step' d='Shop.Theme.Customeraccount'}

+ + + + + + + + + {foreach from=$order.history item=state} + + + + + {/foreach} + +
{l s='Date' d='Shop.Theme.Global'}{l s='Status' d='Shop.Theme.Global'}
{$state.history_date} + + {$state.ostate_name} + +
+
+ {foreach from=$order.history item=state} +
+
{$state.history_date}
+
+ + {$state.ostate_name} + +
+
+ {/foreach} +
+
+ {/block} + + {if $order.follow_up} +
+

{l s='Click the following link to track the delivery of your order' d='Shop.Theme.Customeraccount'}

+ {$order.follow_up} +
+ {/if} + + {block name='addresses'} +
+ {if $order.addresses.delivery} +
+
+

{l s='Delivery address %alias%' d='Shop.Theme.Checkout' sprintf=['%alias%' => $order.addresses.delivery.alias]}

+
{$order.addresses.delivery.formatted nofilter}
+
+
+ {/if} + +
+
+

{l s='Invoice address %alias%' d='Shop.Theme.Checkout' sprintf=['%alias%' => $order.addresses.invoice.alias]}

+
{$order.addresses.invoice.formatted nofilter}
+
+
+
+
+ {/block} + + {$HOOK_DISPLAYORDERDETAIL nofilter} + + {block name='order_detail'} + {if $order.details.is_returnable} + {include file='customer/_partials/order-detail-return.tpl'} + {else} + {include file='customer/_partials/order-detail-no-return.tpl'} + {/if} + {/block} + + {block name='order_carriers'} + {if $order.shipping} +
+ + + + + + + + + + + + {foreach from=$order.shipping item=line} + + + + + + + + {/foreach} + +
{l s='Date' d='Shop.Theme.Global'}{l s='Carrier' d='Shop.Theme.Checkout'}{l s='Weight' d='Shop.Theme.Checkout'}{l s='Shipping cost' d='Shop.Theme.Checkout'}{l s='Tracking number' d='Shop.Theme.Checkout'}
{$line.shipping_date}{$line.carrier_name}{$line.shipping_weight}{$line.shipping_cost}{$line.tracking nofilter}
+
+ {foreach from=$order.shipping item=line} +
+
    +
  • + {l s='Date' d='Shop.Theme.Global'} {$line.shipping_date} +
  • +
  • + {l s='Carrier' d='Shop.Theme.Checkout'} {$line.carrier_name} +
  • +
  • + {l s='Weight' d='Shop.Theme.Checkout'} {$line.shipping_weight} +
  • +
  • + {l s='Shipping cost' d='Shop.Theme.Checkout'} {$line.shipping_cost} +
  • +
  • + {l s='Tracking number' d='Shop.Theme.Checkout'} {$line.tracking nofilter} +
  • +
+
+ {/foreach} +
+
+ {/if} + {/block} + + {block name='order_messages'} + {include file='customer/_partials/order-messages.tpl'} + {/block} +{/block}