Compare commits
4 Commits
b721c153fb
...
v1.0.1
| Author | SHA1 | Date | |
|---|---|---|---|
| a72c8513d1 | |||
|
|
45eeafa1f7 | ||
|
|
5227a50e01 | ||
|
|
7458f80c53 |
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
llmdumper.php
|
||||
.llmdump
|
||||
@@ -20,7 +20,7 @@ class B2BPayments extends PaymentModule implements PrestaShop\PrestaShop\Core\Mo
|
||||
{
|
||||
$this->name = 'b2bpayments';
|
||||
$this->tab = 'payments_gateways';
|
||||
$this->version = '1.0.0';
|
||||
$this->version = '1.0.1';
|
||||
$this->author = 'panariga';
|
||||
$this->need_instance = 0;
|
||||
$this->bootstrap = true;
|
||||
@@ -44,8 +44,9 @@ class B2BPayments extends PaymentModule implements PrestaShop\PrestaShop\Core\Mo
|
||||
{
|
||||
if (
|
||||
!parent::install() ||
|
||||
!$this->registerHook('paymentOptions')
|
||||
|| !$this->registerHook('DisplayOrderConfirmation')
|
||||
!$this->registerHook('paymentOptions') ||
|
||||
!$this->registerHook('DisplayOrderConfirmation') ||
|
||||
!$this->registerHook('actionEmailSendBefore')
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
@@ -411,4 +412,13 @@ class B2BPayments extends PaymentModule implements PrestaShop\PrestaShop\Core\Mo
|
||||
Context::getContext()->customer = $originalCustomer;
|
||||
return $regularPrice;
|
||||
}
|
||||
|
||||
public function hookActionEmailSendBefore($params)
|
||||
{
|
||||
if ($params['template'] == 'bankwire_postpaid') {
|
||||
$params['templateVars']['{bankwire_owner}'] = Configuration::get('BANK_WIRE_OWNER');
|
||||
$params['templateVars']['{bankwire_details}'] = nl2br(Configuration::get('BANK_WIRE_DETAILS'));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -36,9 +36,11 @@ class B2BPaymentsValidationModuleFrontController extends ModuleFrontController
|
||||
$this->context->customer->id;
|
||||
$b2b_postpaid_group_id = (int)Configuration::get('B2BPAYMENTS_POSTPAID_GROUP');
|
||||
$b2b_prepaid_group_id = (int)Configuration::get('B2BPAYMENTS_PREPAID_GROUP');
|
||||
$payment_status = Configuration::get('PS_OS_PAYMENT'); // Default: Payment accepted
|
||||
//$payment_status = Configuration::get('PS_OS_PAYMENT'); // Default: Payment accepted
|
||||
$payment_status = 16; // Default for Prepaid (Avans) - custom status ID 16
|
||||
if ($this->module->isDefaultCustomerGroup($this->context->customer->id, $b2b_postpaid_group_id) && $this->module->isCustomerInGroup($this->context->customer->id, $b2b_postpaid_group_id)) {
|
||||
$payment_status = Configuration::get('PS_OS_PREPARATION'); // Order processing in progress. Adjust as needed.
|
||||
//$payment_status = Configuration::get('PS_OS_PREPARATION'); // Order processing in progress. Adjust as needed.
|
||||
$payment_status = 15; // For Postpaid (Odgoda) - custom status ID 15
|
||||
$payment_method = $this->module->b2b_postpaid_payment_name;
|
||||
} else if ($this->module->isDefaultCustomerGroup($this->context->customer->id, $b2b_prepaid_group_id) && $this->module->isCustomerInGroup($this->context->customer->id, $b2b_prepaid_group_id)) {
|
||||
//Payment Status Already fine.
|
||||
|
||||
@@ -22,38 +22,32 @@
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
|
||||
prestashop.on('updatedProduct', function(updatedData) {
|
||||
applyPriceVisibility(priceToggleSelect.value);
|
||||
});
|
||||
|
||||
const priceToggleSelect = document.getElementById('priceDisplayToggle');
|
||||
|
||||
const storageKey = 'priceDisplayPreference'; // Key for localStorage
|
||||
|
||||
// --- Core Functions ---
|
||||
|
||||
// Function to apply visibility based on preference
|
||||
function applyPriceVisibility(preference) {
|
||||
const vpcElements = document.querySelectorAll('.vpcrender');
|
||||
const mpcElements = document.querySelectorAll('.mpcrender');
|
||||
console.log('Applying preference:', preference); // For debugging
|
||||
console.log('Found VPC elements:', vpcElements.length); // For debugging
|
||||
console.log('Found MPC elements:', mpcElements.length); // For debugging
|
||||
|
||||
switch (preference) {
|
||||
case 'vpc':
|
||||
// Show VPC, Hide MPC
|
||||
vpcElements.forEach(el => el.style.display = ''); // Reset to default display (usually block or inline)
|
||||
vpcElements.forEach(el => el.style.display = '');
|
||||
mpcElements.forEach(el => el.style.display = 'none');
|
||||
break;
|
||||
case 'mpc':
|
||||
// Hide VPC, Show MPC
|
||||
vpcElements.forEach(el => el.style.display = 'none');
|
||||
mpcElements.forEach(el => el.style.display = ''); // Reset to default display
|
||||
mpcElements.forEach(el => el.style.display = '');
|
||||
break;
|
||||
case 'both':
|
||||
default:
|
||||
// Show Both
|
||||
vpcElements.forEach(el => el.style.display = ''); // Reset to default display
|
||||
mpcElements.forEach(el => el.style.display = ''); // Reset to default display
|
||||
vpcElements.forEach(el => el.style.display = '');
|
||||
mpcElements.forEach(el => el.style.display = '');
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -62,10 +56,8 @@
|
||||
function savePreference(preference) {
|
||||
try {
|
||||
localStorage.setItem(storageKey, preference);
|
||||
console.log('Saved preference:', preference); // For debugging
|
||||
} catch (e) {
|
||||
console.error('Failed to save preference to localStorage:', e);
|
||||
// LocalStorage might be disabled or full
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,44 +66,56 @@
|
||||
try {
|
||||
return localStorage.getItem(storageKey);
|
||||
} catch (e) {
|
||||
console.error('Failed to load preference from localStorage:', e);
|
||||
return null; // Return null if localStorage is inaccessible
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// --- Initialization ---
|
||||
// --- Initialization Logic ---
|
||||
|
||||
function initSwitcher() {
|
||||
if (!priceToggleSelect) return;
|
||||
|
||||
// 1. Load saved preference or use default
|
||||
const savedPreference = loadPreference();
|
||||
const currentPreference = (savedPreference && ['both', 'vpc', 'mpc'].includes(savedPreference))
|
||||
? savedPreference
|
||||
: (priceToggleSelect.value || 'both');
|
||||
|
||||
// 2. Sync Select Element and Apply
|
||||
priceToggleSelect.value = currentPreference;
|
||||
applyPriceVisibility(currentPreference);
|
||||
}
|
||||
|
||||
// --- Event Listeners ---
|
||||
|
||||
if (priceToggleSelect) {
|
||||
// 1. Load saved preference
|
||||
const savedPreference = loadPreference();
|
||||
// Initial Load
|
||||
initSwitcher();
|
||||
|
||||
// 2. Set the select element's value and apply visibility
|
||||
if (savedPreference && ['both', 'vpc', 'mpc'].includes(savedPreference)) {
|
||||
priceToggleSelect.value = savedPreference;
|
||||
applyPriceVisibility(savedPreference);
|
||||
} else {
|
||||
// No valid saved preference, use the default value from the select element
|
||||
const initialPreference = priceToggleSelect.value || 'both'; // Fallback to 'both'
|
||||
applyPriceVisibility(initialPreference);
|
||||
// Optionally save the default if nothing was stored
|
||||
// savePreference(initialPreference);
|
||||
// User changes the select dropdown
|
||||
priceToggleSelect.addEventListener('change', function(event) {
|
||||
const selectedPreference = event.target.value;
|
||||
applyPriceVisibility(selectedPreference);
|
||||
savePreference(selectedPreference);
|
||||
});
|
||||
}
|
||||
|
||||
// 3. Add event listener for changes
|
||||
priceToggleSelect.addEventListener('change', function(event) {
|
||||
const selectedPreference = event.target.value;
|
||||
applyPriceVisibility(selectedPreference);
|
||||
savePreference(selectedPreference);
|
||||
// Hook into PrestaShop Events
|
||||
|
||||
// 1. Product Page: Attribute update (e.g. Size S -> Size L)
|
||||
prestashop.on('updatedProduct', function(updatedData) {
|
||||
if(priceToggleSelect) {
|
||||
applyPriceVisibility(priceToggleSelect.value);
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
console.warn('Price display toggle select element (#priceDisplayToggle) not found.');
|
||||
}
|
||||
|
||||
// Initial check in case elements are added dynamically later (less common for prices)
|
||||
// If you expect prices to load via AJAX *after* DOMContentLoaded,
|
||||
// you might need a MutationObserver or trigger applyPriceVisibility again.
|
||||
// For standard page loads, the above should be sufficient.
|
||||
// 2. Category/List Page: AJAX Pagination, Sorting, Filter update
|
||||
prestashop.on('updateProductList', function(data) {
|
||||
if(priceToggleSelect) {
|
||||
// Re-apply the current value of the select box to the newly injected DOM elements
|
||||
applyPriceVisibility(priceToggleSelect.value);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user