Skip to content
This repository was archived by the owner on Jan 11, 2021. It is now read-only.

Commit

Permalink
feat: better receip page
Browse files Browse the repository at this point in the history
  • Loading branch information
olinkl committed May 16, 2019
1 parent 8e088c7 commit ee0abc4
Show file tree
Hide file tree
Showing 2 changed files with 228 additions and 0 deletions.
36 changes: 36 additions & 0 deletions modules/btcpay/btcpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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');
Expand All @@ -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 '&nbsp;<a target="_blank" class="btn btn-default" href="'.$btc_invoice.'">
<i class="icon-file-text"></i>&nbsp;'.
$this->l('Crypto Invoice')
.'</a>';
} 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 .= '<h2>'.$this->l('btcpay').'</h2>';

Expand Down
192 changes: 192 additions & 0 deletions modules/btcpay/themes/pf_strollik/templates/customer/order-detail.tpl
Original file line number Diff line number Diff line change
@@ -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'}
<div id="order-infos">
<div class="box">
<div class="row">
<div class="col-xs-{if $order.details.reorder_url}9{else}12{/if}">
<strong>
{l
s='Order Reference %reference% - placed on %date%'
d='Shop.Theme.Customeraccount'
sprintf=['%reference%' => $order.details.reference, '%date%' => $order.details.order_date]
}
</strong>
</div>
{if $order.details.reorder_url}
<div class="col-xs-3 text-xs-right">
<a href="{$order.details.reorder_url}" class="button-primary btn-primary">{l s='Reorder' d='Shop.Theme.Actions'}</a>
</div>
{/if}
<div class="clearfix"></div>
</div>
</div>

<div class="box">
<ul>
<li><strong>{l s='Carrier' d='Shop.Theme.Checkout'}</strong> {$order.carrier.name}</li>
<li><strong>{l s='Payment method' d='Shop.Theme.Checkout'}</strong> {$order.details.payment}</li>
{if $order.details.payment == 'BTCPay'}
<li><strong>{l s='Crypto Invoice' d='Shop.Theme.Checkout'}</strong> <a target="_blank" href="{$btc_invoice}">{l s='Open' d='Shop.Theme.Checkout'}</a></li>
{/if}

{if $order.details.invoice_url}
<li>
<a href="{$order.details.invoice_url}">
{l s='Download your invoice as a PDF file.' d='Shop.Theme.Customeraccount'}
</a>
</li>
{/if}

{if $order.details.recyclable}
<li>
{l s='You have given permission to receive your order in recycled packaging.' d='Shop.Theme.Customeraccount'}
</li>
{/if}

{if $order.details.gift_message}
<li>{l s='You have requested gift wrapping for this order.' d='Shop.Theme.Customeraccount'}</li>
<li>{l s='Message' d='Shop.Theme.Customeraccount'} {$order.details.gift_message nofilter}</li>
{/if}
</ul>
</div>
</div>
{/block}

{block name='order_history'}
<section id="order-history" class="box">
<h3>{l s='Follow your order\'s status step-by-step' d='Shop.Theme.Customeraccount'}</h3>
<table class="table table-striped table-bordered table-labeled hidden-xs-down">
<thead class="thead-default">
<tr>
<th>{l s='Date' d='Shop.Theme.Global'}</th>
<th>{l s='Status' d='Shop.Theme.Global'}</th>
</tr>
</thead>
<tbody>
{foreach from=$order.history item=state}
<tr>
<td>{$state.history_date}</td>
<td>
<span class="label label-pill {$state.contrast}" style="background-color:{$state.color}">
{$state.ostate_name}
</span>
</td>
</tr>
{/foreach}
</tbody>
</table>
<div class="hidden-sm-up history-lines">
{foreach from=$order.history item=state}
<div class="history-line">
<div class="date">{$state.history_date}</div>
<div class="state">
<span class="label label-pill {$state.contrast}" style="background-color:{$state.color}">
{$state.ostate_name}
</span>
</div>
</div>
{/foreach}
</div>
</section>
{/block}

{if $order.follow_up}
<div class="box">
<p>{l s='Click the following link to track the delivery of your order' d='Shop.Theme.Customeraccount'}</p>
<a href="{$order.follow_up}">{$order.follow_up}</a>
</div>
{/if}

{block name='addresses'}
<div class="addresses">
{if $order.addresses.delivery}
<div class="col-lg-6 col-md-6 col-sm-6">
<article id="delivery-address" class="box">
<h4>{l s='Delivery address %alias%' d='Shop.Theme.Checkout' sprintf=['%alias%' => $order.addresses.delivery.alias]}</h4>
<address>{$order.addresses.delivery.formatted nofilter}</address>
</article>
</div>
{/if}

<div class="col-lg-6 col-md-6 col-sm-6">
<article id="invoice-address" class="box">
<h4>{l s='Invoice address %alias%' d='Shop.Theme.Checkout' sprintf=['%alias%' => $order.addresses.invoice.alias]}</h4>
<address>{$order.addresses.invoice.formatted nofilter}</address>
</article>
</div>
<div class="clearfix"></div>
</div>
{/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}
<div class="box">
<table class="table table-striped table-bordered hidden-sm-down">
<thead class="thead-default">
<tr>
<th>{l s='Date' d='Shop.Theme.Global'}</th>
<th>{l s='Carrier' d='Shop.Theme.Checkout'}</th>
<th>{l s='Weight' d='Shop.Theme.Checkout'}</th>
<th>{l s='Shipping cost' d='Shop.Theme.Checkout'}</th>
<th>{l s='Tracking number' d='Shop.Theme.Checkout'}</th>
</tr>
</thead>
<tbody>
{foreach from=$order.shipping item=line}
<tr>
<td>{$line.shipping_date}</td>
<td>{$line.carrier_name}</td>
<td>{$line.shipping_weight}</td>
<td>{$line.shipping_cost}</td>
<td>{$line.tracking nofilter}</td>
</tr>
{/foreach}
</tbody>
</table>
<div class="hidden-md-up shipping-lines">
{foreach from=$order.shipping item=line}
<div class="shipping-line">
<ul>
<li>
<strong>{l s='Date' d='Shop.Theme.Global'}</strong> {$line.shipping_date}
</li>
<li>
<strong>{l s='Carrier' d='Shop.Theme.Checkout'}</strong> {$line.carrier_name}
</li>
<li>
<strong>{l s='Weight' d='Shop.Theme.Checkout'}</strong> {$line.shipping_weight}
</li>
<li>
<strong>{l s='Shipping cost' d='Shop.Theme.Checkout'}</strong> {$line.shipping_cost}
</li>
<li>
<strong>{l s='Tracking number' d='Shop.Theme.Checkout'}</strong> {$line.tracking nofilter}
</li>
</ul>
</div>
{/foreach}
</div>
</div>
{/if}
{/block}

{block name='order_messages'}
{include file='customer/_partials/order-messages.tpl'}
{/block}
{/block}

0 comments on commit ee0abc4

Please sign in to comment.