Jump to content

Store Collection for selected customers group only


DavidK

Recommended Posts

Hello,I need to modify Store Collection or even some other shipping option to be able to allow it only to certain customer group.Just that it will be offered only to customer in certain group,for example wholesale customers,etc.Would be anybody willing to help or does anybody know some available plugin to enable certain shipping method only to selected group ? Thanks for any help.David

Link to comment
Share on other sites

Let's try a code snippet.

This snippet will require that the targeted shipping module be identified by its folder name, such as Store_Collection. Note the underscore. Make sure that this module is enabled.

Also, the Membership Group ID of the customer group. This will be difficult to determine unless you have access to the database table CubeCart_customer_group.

In admin, Manage Hooks, click the Add Snippet link. When the page refreshes, scroll to the bottom and fill in the form as follows:

Enabled: checked
Unique ID: delShipIfNotCustMem@cc62+
Execution Order: 1
Description: For example- removes Store Collection if customer is not a member of Tax Exempt group
Trigger: class.cart.load_shipping
Version: 1.0
Author: https://forums.cubecart.com/topic/56420-store-collection-for-selected-customers-group-only/
PHP Code:
<?php
## Enter the Customer Group Name:
$snippetCustGroupName = "Tax Exempt";
## Enter the Customer Group 'group_id':
$snippetCustGroupID = 1;
## Enter the shipping module's *folder* name to remove if customer is not in this group:
$snippetKeepThisShippingModuleFolderName = "Store_Collection";
$snippetKeepThisShippingModuleFlag = false;

$snippetUserMembershipArrayIDs = $GLOBALS['user']->getMemberships();

if (is_array($snippetUserMembershipArrayIDs)) {
  $snippetUserMembershipIDs = array();
  foreach ($snippetUserMembershipArrayIDs as $snippetUserMembershipArrayElement) {
    $snippetUserMembershipIDs[] = $snippetUserMembershipArrayElement['group_id'];
  }
  if (in_array($snippetCustGroupID, $snippetUserMembershipIDs)) {
    $snippetKeepThisShippingModuleFlag = true;
  }
}
if (isset($shipArray) && is_array($shipArray) && !$snippetKeepThisShippingModuleFlag) {
    unset($shipArray[$snippetKeepThisShippingModuleFolderName]);
    if (empty($shipArray)) $GLOBALS['cart']->set('shipping', 0);
}

Save and have CubeCart clear its internal cache.

Test with a customer who is a member of the targeted group, and test with a customer who is not a member of the targeted group.

There should be the regular shipping choices at checkout, but for the "special" customer there should be the targeted (i.e., Store Collection) shipping choice as well.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...