View Single Post
  #13  
Old 09-12-2015, 11:07 AM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default Re: Hide the price on the storefront

Okay, Phillipe has engaged me to provide this solution, Thanks.

This is how you can hide prices to anyone that is not a member.

First of all you need to make this modification in your custom module. Here is my tutorial on doing so if you have not done so already: http://kb.x-cart.com/display/XDD/Creating+a+module+for+X-Cart+5%3A+Tutorial+by+Mike+White

The you need to decorate the class Alex referenced above:
classes/XLite/Controller/AController.php
This is demonstrated well here: http://kb.x-cart.com/display/XDD/Step+3+-+applying+logic+changes

Inside your new decorator class place this method:
Code:
/** * Check if current user is a member * * @return boolean */ public function isMember() { $isMember = false; if($this->isLogged()) { $id = \XLite\Core\Auth::getInstance()->getMembershipId(); if ($id > 0) $isMember = true; } return $isMember; }

Now override the templates in your custom skin module. If you need help here is another tutorial on custom skins: http://xcartguru.com/tutorials/x-cart-5-tutorials/building-a-custom-skin-in-x-cart-5/

Override skins/default/en/product/details/parts/common.price.tpl with this:
Code:
{if:isMember()} <widget class="\XLite\View\Price" product="{product}" /> {else:} Must be a member to see prices! {end:}

Override skins/default/en/items_list/product/parts/common.product-price.tpl with this:
Code:
{if:isMember()} <widget class="\XLite\View\Price" product="{product}" displayOnlyPrice="true" /> {else:} Must be a member to see prices! {end:}
Rebuild cache.
__________________
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.
Reply With Quote