X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (X-Cart 5) (https://forum.x-cart.com/forumdisplay.php?f=56)
-   -   Hide the price on the storefront (https://forum.x-cart.com/showthread.php?t=70300)

nandos07 10-21-2014 08:01 PM

Hide the price on the storefront
 
Hi,


I would like to hide the price of my products on my website and only show the price once the customers have logged in, Does anyone have any idea how to do it? Thank you

cflsystems 10-21-2014 08:38 PM

Re: Hide the price on the storefront
 
You posted in XC5 forum but signature says XC4 - so which one is it? Either way though it will require custom coding for this work. If it is for XC4 you can find some tips here on the forum.

nandos07 10-27-2014 11:31 AM

Re: Hide the price on the storefront
 
Quote:

Originally Posted by cflsystems
You posted in XC5 forum but signature says XC4 - so which one is it? Either way though it will require custom coding for this work. If it is for XC4 you can find some tips here on the forum.

I have two x-cart, the other one is still XC 4, my newest store is XC5

tony_sologubov 10-30-2014 03:27 AM

Re: Hide the price on the storefront
 
You will need to write a mod for this task. If you are ready, I can help.
As a first step, please create an empty module according to the guide here:
http://kb.x-cart.com/display/XDD/Step+1+-+creating+simplest+module

Burpomatic 01-30-2015 07:58 AM

Re: Hide the price on the storefront
 
Hello,

I'd also be interested in this. I already have created a module.

Thank you!

totaltec 02-01-2015 05:03 AM

Re: Hide the price on the storefront
 
Look at the code used for the account links. It shows one list when logged in, another when not. So the effect you want should be easily achieved by following that example, overriding the template file with your module and adding the conditional IF statement.

Burpomatic 02-02-2015 03:37 AM

Re: Hide the price on the storefront
 
Hello Mike,

thank you for your answer. Unfortunately I'm not overly familiar with X-cart yet, could you point me which files exactly I should modify with a module?

Thanks again,

totaltec 02-02-2015 04:45 AM

Re: Hide the price on the storefront
 
Ok, so here is the Flexy code that checks if a user is logged in:

Code:

<ul class="account-links" IF="isLogged()">
  Logged in code goes here.
</ul>


I would probably overwrite: default/en/common/price_plain.tpl I haven't tested this but you could try wrapping it in a div like this:
Code:

<div IF="isLogged()">

  <div class="product-price {getFingerprint()}">
  <list name="product.plain_price.head" />
    <ul class="product-price">
    <list name="product.plain_price" />
    </ul>
  <list name="product.plain_price.tail" />
  </div>

</div>


Burpomatic 02-02-2015 06:14 AM

Re: Hide the price on the storefront
 
Thanks Mike, your solution seems to work. For the record, here's what I've done.

Using CustomSkin, I've created the file \xcart\skins\custom_skin\default\en\common\price_p lain.tpl containing the following code :

Quote:

Originally Posted by totaltec
Code:

<div IF="isLogged()">

  <div class="product-price {getFingerprint()}">
  <list name="product.plain_price.head" />
    <ul class="product-price">
    <list name="product.plain_price" />
    </ul>
  <list name="product.plain_price.tail" />
  </div>

</div>



After activating CustomSkin, the prices only show up when signed in. Thanks again for the help!

plh 09-08-2015 01:03 PM

Re: Hide the price on the storefront
 
Hi Mike,


I have added in theme_tweaker/default/en/common/price_parts/price.tpl the following:

<div IF="isLogged()">
<li><span class="price product-price">{formatPrice(getListPrice(),null,1):h}</span></li>
</div
>

This is good but basically as soon as someone hits "Register" and enter an email address (fake or not) and a password he/she is logged in. What statement could we add to have prices showing up ONLY when registrant as been approved, for example, as a wholesaler after a "pending" request?

Thank you for your help.

Philippe

Setting up XCart 5.2.6

qualiteam 09-08-2015 07:28 PM

Re: Hide the price on the storefront
 
Hello Philippe,

What does "approved as a customer" mean? How do you approve them?

Basically, you should decorate \XLite\Controller\AController class, add your method that does the check and use it instead of isLogged() in your template.

plh 09-08-2015 10:47 PM

Re: Hide the price on the storefront
 
Hello Alex,

When products are marked with a specific membership they are not showing.

When products are not marked with a membership class they do show up with prices as soon as someone register, meaning someone entering any kind of information for email and password. The ideal would be for a customer to register and pending admin change of membership prices do not show up.

I failed to find: \XLite\Controller\AController class. Do you mean Classes\XLite\Controller\AController.php? and change:

/**
* Check if current user is logged in
*
* @return boolean
*/
public function isLogged()
{
if (is_null(static::$isLogged)) {
static::$isLogged = \XLite\Core\Auth::getInstance()->isLogged();
}

return static::$isLogged;
}

How do I change it to reflect: Check if Wholesaler is logged in, after admin has changed the user status to "Wholesaler"?

Philippe
Setting up 5.2.6

totaltec 09-12-2015 11:07 AM

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.

designtheweb 07-21-2018 09:55 PM

Re: Hide the price on the storefront
 
hi, is there an update for 5.3? using .twig now.


This link: http://kb.x-cart.com/display/XDD/Creating+a+module+for+X-Cart+5%3A+Tutorial+by+Mike+White no longer exists now.


I cannot see where you can decorate the class.


Any help appreciated.

qualiteam 07-22-2018 12:19 AM

Re: Hide the price on the storefront
 
Quote:

Originally Posted by designtheweb
hi, is there an update for 5.3? using .twig now.


This link: http://kb.x-cart.com/display/XDD/Creating+a+module+for+X-Cart+5%3A+Tutorial+by+Mike+White no longer exists now.


I cannot see where you can decorate the class.


Any help appreciated.



Here is the new link.
https://devs.x-cart.com/webinars_and_video_tutorials/creating_a_module_for_x-cart_5_tutorial_by_mike_white.html


It is still referring to X-Cart 5.1 in that tutorial, but we have a huge bunch of new how-to articles on 5.3.x covered in our new developers docs! Check here.
https://devs.x-cart.com/getting_started/

designtheweb 08-11-2018 10:25 PM

Re: Hide the price on the storefront
 
Thanks but there's no continuity here between the versions so it's impossible to follow. We're now into twigs.

qualiteam 08-12-2018 01:07 AM

Re: Hide the price on the storefront
 
Quote:

Originally Posted by designtheweb
Thanks but there's no continuity here between the versions so it's impossible to follow. We're now into twigs.



Almost all articles that are written by X-Cart staff are adapted to 5.3 now.

designtheweb 09-02-2018 01:24 AM

Re: Hide the price on the storefront
 
Have followed everything but it is hanging when I deploy the store.


Deploying store [step 6 of 13], please wait... Run the "Doctrine_Plugin_ProxyGenerator" plugin...
Run the "Doctrine_Plugin_UpdateModules" plugin... [0.11sec, 1.5MB (601kB)]

qualiteam 09-03-2018 01:22 AM

Re: Hide the price on the storefront
 
Quote:

Originally Posted by designtheweb
Have followed everything but it is hanging when I deploy the store.


Deploying store [step 6 of 13], please wait... Run the "Doctrine_Plugin_ProxyGenerator" plugin...
Run the "Doctrine_Plugin_UpdateModules" plugin... [0.11sec, 1.5MB (601kB)]



Is there anything in the error log?
If there is nothing, I would advise to drop X-Cart cache (var/run and var/datacache) and then regenerate the cache manually through PHP-CLI while logged in to the server console over SSH, like this.


Code:

for asdasd in {1..13}; do php admin.php; done;


Most likely it will throw an error you are looking for.


All times are GMT -8. The time now is 05:56 AM.

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