| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | User manuals | Login |
hiding a shipping option based on user | ||||
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
hiding a shipping option based on user
I have a shipping option "in store pickup" that I only want to show up if a user is a wholesale account.
The id's are as follows membershipid 2 (wholesale) shippingid 201 (in store pickup) I am using altered carts checkout one mod and reboot template. I'm not sure where the shipping methods are pulled from for altered carts checkout page... I have an IF statement like this... Code:
I have put this if statement in common_files/modules/fast_lane_checkout/shipping_methods.tpl common_files/modules/one_page_checkout/shipping_methods.tpl reboot/modules/fast_lane_checkout/shipping_methods.tpl reboot/modules/one_page_checkout/shipping_methods.tpl I had this code working in my 4.4.5. site but can't get it to work in my new 4.6.6. site. It looks like it is working when I estimate shipping in the shopping cart but it is hard to tell since you can't see the shipping rates there if you are logged in. I can't get it to work on the checkout page though. I have also tried switching back and forth between fast lane and one page checkout in the general settings but still no go.
__________________
www.uscandleco.com - X-Cart Version 4.7.11 Gold Plus php7.3 mods: reCaptcha running on UNIX www.keystonecandle.com X-Cart Gold Plus - Version 4.7.11 php7.2 mods: reCaptcha cdseo pro running on UNIX |
|||||||
#2
|
|||||||
|
|||||||
Re: hiding a shipping option based on user
Hi Keystone,
I think the following file might be Altered Carts file containing the shipping_methods.tpl code. Code:
Thank you again for your comments on my site when you were evaluating reBOOT. Good Luck! Paul
__________________
X-Cart GoldPlus v4.7.12 | reBOOT (reDUX) Template v4.7.12.9 | Always The Best |
|||||||
|
#3
|
|||||||||
|
|||||||||
Re: hiding a shipping option based on user
Once you have found the loop of shipping methods, you need to determine the ID of the method you want to hide. Then you need the id of the membership level you want it to be associated with. Then you can concoct your if statement, {if $userinfo.membershipid = X} Show radio {/if}
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey XcartGuru X-cart Tutorials | X-cart 5 Tutorials Check out the responsive template for X-cart. |
|||||||||
#4
|
|||||||||
|
|||||||||
Re: hiding a shipping option based on user
I prefer to do this in php rather than the templates. For 4.6 in include/func/func.shipping.php in func_is_shipping_method_allowable() toward the top add something like this:
PHP Code:
|
|||||||||
|
#5
|
|||||||
|
|||||||
Re: hiding a shipping option based on user
Hi Cherie, Thanks for that. Seems much more neat and clean, plus then you don't have to hunt down all the different templates.
__________________
www.uscandleco.com - X-Cart Version 4.7.11 Gold Plus php7.3 mods: reCaptcha running on UNIX www.keystonecandle.com X-Cart Gold Plus - Version 4.7.11 php7.2 mods: reCaptcha cdseo pro running on UNIX |
|||||||
#6
|
|||||||||
|
|||||||||
Re: hiding a shipping option based on user
Changes directly in php files must be done wisely as they will make future upgrades difficult. And this is very much hardcoding your way there.
You can also do it with smarty function which will require the least changes to stock system
__________________
Steve Stoyanov CFLSystems.com Web Development |
|||||||||
#7
|
|||||||
|
|||||||
Re: hiding a shipping option based on user
Hi Steve,
Could you give an example of how you would do it with smarty?
__________________
www.uscandleco.com - X-Cart Version 4.7.11 Gold Plus php7.3 mods: reCaptcha running on UNIX www.keystonecandle.com X-Cart Gold Plus - Version 4.7.11 php7.2 mods: reCaptcha cdseo pro running on UNIX |
|||||||
#8
|
|||||||||
|
|||||||||
Re: hiding a shipping option based on user
Look in any function file under include/template/plugins directory - these are smarty function which you can call directly from any template, pass to it the shipping methods array and do the check for whatever you need, adjust the array and return it back to the template. That way you make a small change in the template and all the php code you need for this is in your own file so not messing up with the system.
So if the file is function.change_shipping_methods.php you can call it in the template as {change_shipping_method shipping=$SHIPPING_ARRAY membershipid=$USER_MEMBERSHIPID assign="SHIPPING_ARRAY"} And then have the code that uses that shipping array which will already be modified. Now I just mentioned this as one possibility. That doesn't mean it is always the best way to do it. But in this case it may just be the better option...
__________________
Steve Stoyanov CFLSystems.com Web Development |
|||||||||
|
#9
|
|||||||||
|
|||||||||
Re: hiding a shipping option based on user
Cherie's solution is cleaner and possibly simpler, though I really like Steve's way. The template change I suggested is one of the easiest, and if you are working in a custom skin directory then it will not conflict with any future upgrade, though you might end up rebuilding your skin after the upgrade. I think Steve's solution is the winner. So many ways to skin the cat.
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey XcartGuru X-cart Tutorials | X-cart 5 Tutorials Check out the responsive template for X-cart. |
|||||||||
#10
|
|||||||||
|
|||||||||
Re: hiding a shipping option based on user
It would be interesting to see an example of just how simple a Smarty plugin could be made to accomplish this. Maybe only a few more lines than our two-liner? The problem might be tracking down all areas where $SHIPPING_ARRAY is used to add the plugin call which kind of defeats the purpose of a simple solution.
|
|||||||||
|
|||
X-Cart forums © 2001-2020
|