Jump to content

Store Collection for selected customers group only


DavidK
 Share

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: [email protected]+
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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...