X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Free shipping by membership level (https://forum.x-cart.com/showthread.php?t=60983)

ehermanson 09-22-2011 11:14 PM

Free shipping by membership level
 
For Version 4.4.2
This only determines if a customer gets free shipping or not based on membership level.
It cannot determine what the shipping method is or exactly how much.

/************************************ In this location *********************************/

in "XCart\include\func\func.cart.php" at approximately line 1546
in function "func_calculate_shippings" after;

/************************************ After this code **********************************/

foreach($products as $k => $product) {
if (@$product['deleted']) continue; // for Advanced_Order_Management module
if (
!empty($active_modules['Egoods'])
&& $product['distribution'] != ''
) {
continue;
}

/***************************** Shipping by membership mod ******************************/

global $user_account;

if (!empty($user_account['membership'])
&& ($user_account['membership'] == 'Family' || $user_account['membership'] == 'Friends'))
{
$product['free_shipping'] = 'Y';
}

/************************************ Before this code **********************************/

// Calculate total_cost and total_weight for selection condition

if (
$product['free_shipping'] != 'Y'
|| $config['Shipping']['free_shipping_weight_select'] == 'Y'
) {
$total_cost['valid']['DST'] += $product['subtotal'];
$total_cost['valid']['ST'] += price_format($product['price'] * $product['amount']);
$total_weight['valid'] += $product['weight'] * $product['amount'];
}

/************************************************** *************************************/

AIEGaming 12-07-2011 06:49 AM

Re: Free shipping by membership level
 
Is there a way to offer certain shipping methods based on membership level? We need one of our wholesale customers to be able to choose UPS Ground or Next Day Air but both of them being zero cost to them. We will be shipping using their UPS account so we don't charge them for shipping. I made 2 new shipping methods for them called:

Company Name UPS Ground
Company Name UPS Next Day Air

The problem is, I don't want other customers to be able to use those shipping methods because as I mentioned earlier, they are free. Do you know of a way for us to accomplish this?

AIEGaming 12-07-2011 08:00 AM

Re: Free shipping by membership level
 
Actually... since their shipping would always be free would the above method work for what I'm trying to do? Could they still select UPS Ground or Next Day Air and just not be charged for it but regular customers would be charged the normal amount?

dtgmap 10-22-2012 01:07 PM

Re: Free shipping by membership level
 
I finally figured this out after combining info from these 2 posts:

http://forum.x-cart.com/showthread.php?t=9081&highlight=shippingid
http://forum.x-cart.com/showthread.php?t=60983

1) Create an entry in xcart_config that has the following values:
name: free_shipping_allowed_method
comment: FREE SHIPPING ALLOWED METHOD
Give free shipping on a certain shipping method (Example: FedEx Ground is 43)
value: 0
category: Shipping
orderby: 4
type: text
defvalue: 0

2) In include/func/func.cart.php, insert this code:

Code:

if ($config['Shipping']['free_shipping_allowed_method'] == $shipping_id && $user_account['membership'] == 'Friends'){
                $shipping_cost = 0;
}



BEFORE


Code:

    $display_shipping_cost = $shipping_cost;

    if (
        $calculate_enable_flag
        && !(
            @$customer_info['tax_exempt'] == 'Y'
            && (
                $config['Taxes']['enable_user_tax_exemption'] == 'Y'
                || defined('XAOM')
            )
        )
    ) {

        // Calculate taxes cost



3) Go into the x-cart admin, under Shipping Options, and set your shipping method
(This number will be the shippingid in the xcart_shipping table)

If you have any questions, there is valuable info in the 2 posts I referenced, such as applying to multiple shipping methods.

Note: This code change may affect your coupons. I don't currently have any set up, so I haven't tested it yet, but one of the posts addresses this scenario.


All times are GMT -8. The time now is 06:39 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.