(main): Add module
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
#gift-paper-choice {
|
||||
margin-top: 12px;
|
||||
padding: 12px 16px;
|
||||
background: #f9f9f9;
|
||||
border: 1px solid #e0e0e0;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
#gift-paper-choice legend,
|
||||
#gift-paper-choice .gift-paper-label {
|
||||
font-weight: 600;
|
||||
margin-bottom: 8px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
#gift-paper-choice .gift-paper-options {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
#gift-paper-choice .gift-paper-option {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#gift-paper-choice .gift-paper-option input[type="radio"] {
|
||||
margin: 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
var panel = document.getElementById("ws-gift-panel");
|
||||
var badge = document.querySelector('[data-badge="gift"]');
|
||||
if (!panel || !badge) return;
|
||||
badge.textContent = "Cadeauverpakking - " + panel.dataset.paperChoice;
|
||||
});
|
||||
@@ -0,0 +1,33 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
function savePaperChoice(choice) {
|
||||
var ajaxUrl = window.wsGiftDropdownAjaxUrl || '';
|
||||
if (!ajaxUrl || !choice) {
|
||||
return;
|
||||
}
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('POST', ajaxUrl, true);
|
||||
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||||
xhr.send('gift_paper=' + encodeURIComponent(choice) + '&ajax=1');
|
||||
}
|
||||
|
||||
function init() {
|
||||
var checked = document.querySelector('input[name="gift_paper"]:checked');
|
||||
if (checked) {
|
||||
savePaperChoice(checked.value);
|
||||
}
|
||||
|
||||
document.addEventListener('change', function (e) {
|
||||
if (e.target && e.target.name === 'gift_paper') {
|
||||
savePaperChoice(e.target.value);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', init);
|
||||
} else {
|
||||
init();
|
||||
}
|
||||
}());
|
||||
@@ -0,0 +1,35 @@
|
||||
{if $confirmation}
|
||||
{$confirmation nofilter}
|
||||
{/if}
|
||||
|
||||
<div class="panel">
|
||||
<div class="panel-heading">
|
||||
<i class="icon-gift"></i>
|
||||
{l s='Gift Paper Options' mod='ws_giftdropdown'}
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<p class="help-block">
|
||||
{l s='Enter one paper style per line. These options will appear as radio buttons in the checkout when the customer selects gift wrapping.' mod='ws_giftdropdown'}
|
||||
</p>
|
||||
<form method="post" action="{$form_action|escape:'htmlall':'UTF-8'}">
|
||||
<div class="form-group">
|
||||
<label for="gift_options" class="control-label">
|
||||
{l s='Paper styles (one per line)' mod='ws_giftdropdown'}
|
||||
</label>
|
||||
<textarea
|
||||
id="gift_options"
|
||||
name="gift_options"
|
||||
class="form-control"
|
||||
rows="8"
|
||||
style="font-family: monospace;"
|
||||
>{$gift_options|escape:'htmlall':'UTF-8'}</textarea>
|
||||
</div>
|
||||
<div class="panel-footer">
|
||||
<button type="submit" name="submitWsGiftDropdown" class="btn btn-default pull-right">
|
||||
<i class="process-icon-save"></i>
|
||||
{l s='Save' mod='ws_giftdropdown'}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,12 @@
|
||||
<div class="panel" id="ws-gift-panel" data-paper-choice="{$gift_paper_choice|escape:'htmlall':'UTF-8'}">
|
||||
<div class="panel-heading">
|
||||
<i class="icon-gift"></i>
|
||||
{l s='Gift wrapping' mod='ws_giftdropdown'}
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<dl class="list-unstyled">
|
||||
<dt>{l s='Paper style' mod='ws_giftdropdown'}</dt>
|
||||
<dd><strong>{$gift_paper_choice|escape:'htmlall':'UTF-8'}</strong></dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user