switcher always visible, but postpaid option only if in postpaid customer group. Removed inline style

This commit is contained in:
Mihael
2025-06-02 17:05:24 +02:00
parent 3bc20eafd7
commit d043ef29a2
2 changed files with 14 additions and 16 deletions

View File

@@ -316,16 +316,19 @@ class B2BPayments extends PaymentModule implements PrestaShop\PrestaShop\Core\Mo
{
$customer = $this->context->customer;
$group_ids = Customer::getGroupsStatic((int)$customer->id);
$postpaid_group_id = (int)Configuration::get('B2BPAYMENTS_POSTPAID_GROUP');
$prepaid_group_id = (int)Configuration::get('B2BPAYMENTS_PREPAID_GROUP');
if ($customer->isLogged() && $this->isCustomerInGroup($customer->id, $postpaid_group_id) && $this->isCustomerInGroup($customer->id, $prepaid_group_id)) {
if ($customer->isLogged() /*&& $this->isCustomerInGroup($customer->id, $postpaid_group_id)*/ && $this->isCustomerInGroup($customer->id, $prepaid_group_id)) {
return array(
'show_switch' => true,
'postpaid_group_id' => $postpaid_group_id,
'prepaid_group_id' => $prepaid_group_id,
'current_group_is_postpaid' => $this->isDefaultCustomerGroup($customer->id, $postpaid_group_id),
'switch_url' => $this->context->link->getModuleLink($this->name, 'switch', array(), true)
'switch_url' => $this->context->link->getModuleLink($this->name, 'switch', array(), true),
'customer_groups' => $group_ids
);
}

View File

@@ -1,14 +1,7 @@
{if $show_switch}
<style>
.payments-selection {
justify-content: flex-end;
margin: 10px 0;
}
</style>
<div class="payment-switcher">
<div class="payment-switcher">
<div class="payments-selection">
{* The select dropdown *}
<select id="b2b-group-select" name="b2b_group_type" class="custom-select" onchange="switchB2Bpayment();">
@@ -17,14 +10,16 @@
{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>
{* Option for Postpaid
* show only if customer is in group "B2B Odgoda placanja" *}
{if in_array(5, $customer_groups)}
<option value="postpaid" {if $current_group_is_postpaid}selected{/if}>
{l s='Postpaid' d='Modules.B2bpayments.ShopBreadcrumb'}
</option>
{/if}
</select>
</div>
</div>
</div>