fix(main): Use hookActionValidateOrderAfter; update to-do's ReadMe
This commit is contained in:
@@ -4,4 +4,57 @@ A companion module for thecheckout. Adds gift wrapping options when a user wants
|
||||
|
||||
This module requires thecheckout module to be installed.
|
||||
|
||||
Todo: Make the module more portable when it comes to mail and PDF templates. Right now you have to manually add {ws_gift_paper_choice} to the mail templates
|
||||
Todo:
|
||||
1.) Make the module more portable when it comes to mail and PDF templates. Right now you have to manually add {ws_gift_paper_choice} to the mail templates
|
||||
|
||||
`order_conf.html:`
|
||||
|
||||
```html
|
||||
<tr>
|
||||
<td
|
||||
align="left"
|
||||
style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-size: 0px; padding: 10px 25px; padding-top: 0; word-break: break-word;"
|
||||
>
|
||||
<div
|
||||
style="font-family: Open sans, arial, sans-serif; font-size: 16px; line-height: 25px; text-align: left; color: #363a41;"
|
||||
align="left"
|
||||
>
|
||||
<span class="label" style="font-weight: 700;">Cadeaupapier</span>
|
||||
{ws_gift_paper_choice}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
```
|
||||
|
||||
2.) Make the module more portable when it comes to adding the radio buttons in the checkout. Right now we have to manually add to the tpl: `themes/falcon/modules/thecheckout/views/templates/front/blocks/shipping.tpl`
|
||||
|
||||
```smarty
|
||||
{if isset($gift_paper_options) && $gift_paper_options|count}
|
||||
<div id="gift-paper-choice">
|
||||
<span class="gift-paper-label">{l s='Kies je cadeaupapier' d='Admin.Modules.ws_giftdropdown'}</span>
|
||||
<div class="gift-paper-options">
|
||||
{foreach from=$gift_paper_options item=option}
|
||||
<label class="gift-paper-option">
|
||||
<input type="radio" name="gift_paper" value="{$option|escape:'htmlall':'UTF-8'}">
|
||||
{$option|escape:'htmlall':'UTF-8'}
|
||||
</label>
|
||||
{/foreach}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
```
|
||||
|
||||
3.) Make this translatable in displayHooks.php
|
||||
|
||||
```
|
||||
if ($paperChoice) {
|
||||
$note = 'Cadeaupapier: ' . $paperChoice;
|
||||
$order->note = $order->note ? $order->note . "\n" . $note : $note;
|
||||
$order->update();
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
4.) Instead of mod='ws_giftdropdown' say d='Admin.Modules.ws_giftdropdown'
|
||||
|
||||
5.) Make paper choice an entity
|
||||
|
||||
@@ -6,7 +6,7 @@ class Config
|
||||
{
|
||||
const HOOKS = [
|
||||
'actionGetExtraMailTemplateVars',
|
||||
'actionValidateOrder',
|
||||
'actionValidateOrderAfter',
|
||||
'actionFrontControllerSetMedia',
|
||||
'displayAdminOrderMainBottom',
|
||||
'displayHeader',
|
||||
|
||||
@@ -22,7 +22,6 @@ trait DisplayHooks
|
||||
|
||||
$this->context->smarty->assign('gift_paper_options', $options);
|
||||
|
||||
return $this->display(__FILE__, 'views/templates/hook/your_template.tpl');
|
||||
}
|
||||
|
||||
public function hookActionGetExtraMailTemplateVars(array $params): void
|
||||
@@ -35,7 +34,7 @@ trait DisplayHooks
|
||||
$params['extra_template_vars']['{ws_gift_paper_choice}'] = $paperChoice;
|
||||
}
|
||||
|
||||
public function hookActionValidateOrder(array $params)
|
||||
public function hookActionValidateOrderAfter(array $params)
|
||||
{
|
||||
/** @var Order $order */
|
||||
$order = $params['order'];
|
||||
|
||||
Reference in New Issue
Block a user