first commit
This commit is contained in:
132
views/templates/hook/b2b_switch.tpl
Normal file
132
views/templates/hook/b2b_switch.tpl
Normal file
@@ -0,0 +1,132 @@
|
||||
<div class="b2b-group-switch">
|
||||
{if $show_switch}
|
||||
{* <p>{l s='Switch to:' mod='b2bpayments'}</p> *}
|
||||
<label class="switch">
|
||||
<input type="checkbox" id="b2b-switch" {if $current_group_is_postpaid}checked{/if}>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
{if $current_group_is_postpaid}
|
||||
{l s='Postpaid' d='Modules.B2bpayments.ShopSwitch'}
|
||||
{else}
|
||||
{l s='Prepaid' d='Modules.B2bpayments.ShopSwitch'}
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const b2bSwitch = document.getElementById('b2b-switch');
|
||||
|
||||
if (b2bSwitch) {
|
||||
b2bSwitch.addEventListener('change', function() {
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open('POST', '{$switch_url}');
|
||||
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); // Required for POST requests
|
||||
|
||||
xhr.onload = function() {
|
||||
if (xhr.status >= 200 && xhr.status < 300) {
|
||||
try {
|
||||
const response = JSON.parse(xhr.responseText);
|
||||
if (response.success) {
|
||||
location.reload(); // Refresh the page
|
||||
} else {
|
||||
alert('{$error_message|escape:'javascript'}'); // Use the error message, escaping it
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('JSON Parsing Error:', e);
|
||||
alert('An error occurred while processing the response. Please try again.');
|
||||
}
|
||||
} else {
|
||||
console.error('HTTP Error:', xhr.status, xhr.statusText);
|
||||
alert('An error occurred while switching groups. Please try again.');
|
||||
}
|
||||
};
|
||||
|
||||
xhr.onerror = function() {
|
||||
console.error('Request failed');
|
||||
alert('An error occurred while switching groups. Please try again.');
|
||||
};
|
||||
|
||||
const params = 'ajax=true&action=switchGroup'; // Build the query string
|
||||
xhr.send(params);
|
||||
});
|
||||
} else {
|
||||
console.warn('b2b-switch element not found.'); // Log a warning if the switch is not present
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.b2b-group-switch {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.b2b-group-switch p {
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
/* The switch - the box around the slider */
|
||||
.switch {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
width: 60px;
|
||||
height: 34px;
|
||||
}
|
||||
|
||||
/* Hide default HTML checkbox */
|
||||
.switch input {
|
||||
opacity: 0;
|
||||
width: 0;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
/* The slider */
|
||||
.slider {
|
||||
position: absolute;
|
||||
cursor: pointer;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: #ccc;
|
||||
-webkit-transition: .4s;
|
||||
transition: .4s;
|
||||
}
|
||||
|
||||
.slider:before {
|
||||
position: absolute;
|
||||
content: "";
|
||||
height: 26px;
|
||||
width: 26px;
|
||||
left: 4px;
|
||||
bottom: 4px;
|
||||
background-color: white;
|
||||
-webkit-transition: .4s;
|
||||
transition: .4s;
|
||||
}
|
||||
|
||||
input:checked + .slider {
|
||||
background-color: #2196F3;
|
||||
}
|
||||
|
||||
input:focus + .slider {
|
||||
box-shadow: 0 0 1px #2196F3;
|
||||
}
|
||||
|
||||
input:checked + .slider:before {
|
||||
-webkit-transform: translateX(26px);
|
||||
-ms-transform: translateX(26px);
|
||||
transform: translateX(26px);
|
||||
}
|
||||
|
||||
/* Rounded sliders */
|
||||
.slider.round {
|
||||
border-radius: 34px;
|
||||
}
|
||||
|
||||
.slider.round:before {
|
||||
border-radius: 50%;
|
||||
}
|
||||
</style>
|
||||
74
views/templates/hook/breadcrumb.tpl
Normal file
74
views/templates/hook/breadcrumb.tpl
Normal file
@@ -0,0 +1,74 @@
|
||||
{if $show_switch}
|
||||
<style>
|
||||
.payments-selection {
|
||||
justify-content: flex-end;
|
||||
margin: 10px 0;
|
||||
}
|
||||
</style>
|
||||
<div class="col-md-6 col-lg-3">
|
||||
<div class="payments-selection">
|
||||
|
||||
|
||||
{* The select dropdown *}
|
||||
<select id="b2b-group-select" name="b2b_group_type" class="custom-select" onchange="switchB2Bpayment();">
|
||||
|
||||
{* Option for Prepaid *}
|
||||
<option value="prepaid" {if !$current_group_is_postpaid}selected{/if}>
|
||||
{l s='Prepaid' d='Modules.B2bpayments.ShopBreadcrumb'}
|
||||
</option>
|
||||
|
||||
{* Option for Postpaid *}
|
||||
<option value="postpaid" {if $current_group_is_postpaid}selected{/if}>
|
||||
{l s='Postpaid' d='Modules.B2bpayments.ShopBreadcrumb'}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
function switchB2Bpayment() {
|
||||
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open('POST', '{$switch_url|escape:'javascript'}');
|
||||
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); // Required for POST requests
|
||||
|
||||
xhr.onload = function() {
|
||||
if (xhr.status >= 200 && xhr.status < 300) {
|
||||
try {
|
||||
const response = JSON.parse(xhr.responseText);
|
||||
if (response.success) {
|
||||
// Success: Reload the page to reflect the change
|
||||
location.reload();
|
||||
} else {
|
||||
|
||||
alert('{$error_message|escape:'javascript'}');
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('JSON Parsing Error:', e, xhr.responseText);
|
||||
alert('An error occurred while processing the response. Please try again.');
|
||||
}
|
||||
} else {
|
||||
// HTTP error: Show generic error
|
||||
console.error('HTTP Error:', xhr.status, xhr.statusText);
|
||||
alert('An error occurred while switching groups (HTTP ' + xhr.status + '). Please try again.');
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
xhr.onerror = function() {
|
||||
// Network or other request error
|
||||
console.error('Request failed');
|
||||
alert(
|
||||
'An error occurred while switching groups (Network Error). Please check your connection and try again.'
|
||||
);
|
||||
|
||||
};
|
||||
const params = 'ajax=true&action=switchGroup'; // Build the query string
|
||||
xhr.send(params);
|
||||
};
|
||||
</script>
|
||||
{/if}
|
||||
24
views/templates/hook/displayOrderConfirmation.tpl
Normal file
24
views/templates/hook/displayOrderConfirmation.tpl
Normal file
@@ -0,0 +1,24 @@
|
||||
{**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*}
|
||||
|
||||
<div id="b2bpayments-displayOrderConfirmation">
|
||||
{if $b2b_order_confirmation_message}
|
||||
<p>{$b2b_order_confirmation_message}</p>
|
||||
{/if}
|
||||
</section>
|
||||
22
views/templates/hook/postpaidAdditionalInformation.tpl
Normal file
22
views/templates/hook/postpaidAdditionalInformation.tpl
Normal file
@@ -0,0 +1,22 @@
|
||||
{**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*}
|
||||
|
||||
<section id="b2bpayments-postpaidAdditionalInformation">
|
||||
<p>{l s='You pay after 5 days' d='Modules.B2bpayments.PaymentAdditionalInformation'}</p>
|
||||
</section>
|
||||
22
views/templates/hook/prepaidAdditionalInformation.tpl
Normal file
22
views/templates/hook/prepaidAdditionalInformation.tpl
Normal file
@@ -0,0 +1,22 @@
|
||||
{**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*}
|
||||
|
||||
<section id="b2bpayments-prepaidAdditionalInformation">
|
||||
<p>{l s='You pay in advance' d='Modules.B2bpayments.PaymentAdditionalInformation'}</p>
|
||||
</section>
|
||||
Reference in New Issue
Block a user