VirtueMart Forum

VirtueMart 2 + 3 + 4 => Plugins: Payment, Shipment and others => Topic started by: sandomatyas on December 02, 2024, 13:00:29 PM

Title: Payment methods for shopper groups only
Post by: sandomatyas on December 02, 2024, 13:00:29 PM
Hello, everyone! I've built a shop that uses reseller shopper groups. However, it seems I can't add a payment method exclusively for non-resellers. If I set it to "guests only," it doesn't show for registered users. On the other hand, if I include the default shopper group, it becomes visible to resellers as well.
Title: Re: Payment methods for shopper groups only
Post by: sandomatyas on December 17, 2024, 12:49:43 PM
I believe the issue is in the getPluginMethods() method of the file:

administrator/components/com_virtuemart/plugins/vmpsplugin.php

Specifically, in the following part of the code:

$usermodel = VmModel::getModel( 'user' );
$user = $usermodel->getUser($userId);
$user->shopper_groups = (array)$user->shopper_groups;

When I log in as a reseller and dump $user->shopper_groups, I get the following result:

Kód másolása
Array
(
    [0] => 13
    [1] => 2
)

The problem is that 2 (the default group) appears in the list of shopper groups. As a result, all shipping methods assigned to the default group are also listed for resellers, which is not the desired behavior.