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)
-   -   Hiding product weights and inventory quantities (https://forum.x-cart.com/showthread.php?t=70518)

More-Japan 11-13-2014 08:58 AM

Hiding product weights and inventory quantities
 
By default X-Cart 5 shows all product weights and inventory quantities. I would like to hide this from the storefront. Anyone know how this can be done? Is there a module or somewhere in the template files I can hide the code that displays these values?

SignTorch 11-17-2014 01:39 AM

Re: Hiding product weights and inventory quantities
 
there may be a better way, but this worked for me

to hide the weight, using custom skins module

copy skins\default\en\product\details\common_attributes \common.product-attributes.weight.tpl

to skins\custom_skin\default\en\product\details\commo n_attributes\common.product-attributes.weight.tpl

and comment out the template code

Code:

{*
<li IF="!getWeight()=0">
  <div><strong>{t(#Weight#)}</strong></div>
  <span>{formatWeight(getWeight())}</span>
</li>
*}


I'm not using inventory, so I'd guess for inventory maybe do the same with this template

skins\default\en\product\details\parts\common.stoc k.tpl

More-Japan 11-17-2014 02:43 PM

Re: Hiding product weights and inventory quantities
 
Thank you. I was able to hide the product quantities through the template files.

Hanypa 02-21-2015 08:52 PM

Re: Hiding product weights and inventory quantities
 
You can also do it with custom css in the back of xcart with

Code:

/* Hide quantity available */
.product-items-available {
display: none;
}
/* Hide weight in check out */
.item-weight {
display: none;
}

/* Hide weight & SKU in item description */
.product-details-tabs {
display: none;
}


This way you don't have to modify any files, which makes upgrading a little easier.

minfinger 03-07-2015 07:12 PM

Re: Hiding product weights and inventory quantities
 
Hanypa,

Your way works, but that hides the product description too. I'm interersted in only hiding the Weight & SKU.

Perhaps a combination of Custom Skin and your CSS?

Or is there a way to build a Module to do this?

Wing Fat 08-01-2015 07:10 PM

Re: Hiding product weights and inventory quantities
 
Quote:

Originally Posted by minfinger
Hanypa,

Your way works, but that hides the product description too. I'm interersted in only hiding the Weight & SKU.

Try this instead:
Code:

/* Hide weight & SKU in item description */
.extra-fields {
    display: none;
}


razortw 08-05-2015 12:18 AM

Re: Hiding product weights and inventory quantities
 
Quote:

Originally Posted by minfinger
Hanypa,

Your way works, but that hides the product description too. I'm interersted in only hiding the Weight & SKU.

Perhaps a combination of Custom Skin and your CSS?

Or is there a way to build a Module to do this?

There is no need in editing templats.
Just add this to 'Custom CSS':
Code:

.product-details .extra-fields {
  display: none;
}


Oren 03-09-2016 11:07 AM

Re: Hiding product weights and inventory quantities
 
Quote:

Originally Posted by razortw
There is no need in editing templats.
Just add this to 'Custom CSS':
Code:

.product-details .extra-fields {
  display: none;
}


This did not work for me with version 5.2.13.

Also, the weight also appears in the cart, and I'd like to hide it there as well. Any idea how to do that?

minfinger 03-11-2016 04:22 AM

Re: Hiding product weights and inventory quantities
 
Idk what to tell you, I just upgraded the site and mine is working fine.

Oren 03-12-2016 02:44 AM

Re: Hiding product weights and inventory quantities
 
It works now. Not sure what was the problem. But the shopping cart still shows weight. How do I hide it from there as well?

qualiteam 03-13-2016 09:04 PM

Re: Hiding product weights and inventory quantities
 
The weight is displayed by this template file:
skins/default/en/shopping_cart/parts/item.info.weight.tpl

If you check the file, it has the @ListChild directive that says that the template must be shown in the "cart.item.info" list. So, to removing the template from that list should be enough to hide the weight in the shopping cart.

I haven't tested the following code, but creating a custom module and adding the following method to your Main.php (or doing the same for Custom Skin module) should work:
PHP Code:

protected static function moveTemplatesInLists()
    {
        return array(
            
'shopping_cart/parts/item.info.weight.tpl' => array(
                static::
TO_DELETE => array(
                    array(
'cart.item.info', \XLite\Model\ViewList::INTERFACE_CUSTOMER)
                ),
            ),
        );
    } 


kevinrm 03-14-2016 08:59 PM

Re: Hiding product weights and inventory quantities
 
This is how I hide stock quantities - I don't want my competitors knowing how much inventory I keep.

1) Look&Feel>>Webmaster mode

2) Edit Template: /default/en/product/details/stock/body.tpl

Comment out the quantity tag using {** *} here is the template:
================================================

{* vim: set ts=2 sw=2 sts=2 et: *}

{**
* Product stock
*
* @author Qualiteam software Ltd <info@x-cart.com>
* @copyright Copyright (c) 2011-2015 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
* @license http://www.x-cart.com/license-agreement.html X-Cart 5 License Agreement
* @link http://www.x-cart.com/
*}

<div class="product-stock {getFingerprint()}">
{if:isInStock()}
<span class="stock-level product-in-stock">
<span class="in-stock-label">{t(#In stock#)}</span>


{**
<span class="product-items-available">({t(#X items available#,_ARRAY_(#count#^getAvailableAmount()))} )</span>
*}


</span>
{else:}
{if:isOutOfStock()}
<span class="stock-level product-out-of-stock">{getOutOfStockMessage()}</span>
{end:}
{end:}
</div>

CorpWest 11-06-2017 08:17 AM

Re: Hiding product weights and inventory quantities
 
What about hiding JUST the weight and keeping the SKU?
Would this work?
.product-details .extra-fields { display: weight; }

Triple A Racing 11-09-2017 01:11 AM

Re: Hiding product weights and inventory quantities
 
Quote:

Originally Posted by CorpWest
What about hiding JUST the weight and keeping the SKU?
Would this work? .product-details .extra-fields { display: weight; }

If you use a custom module to provide your site changes, it's quite easy to then apply your "own version" of the relevant twig files, which in this thread's main discussion cases would be:

/skins/**your-custom-module**/customer/product/details/stock/body.twig for stock levels

/skins/**your-custom-module**/customer/product/details/common_attributes/common.product-attributes.weight.twig for weights

And if you needed to modify the sku display, that's here too:

/skins/**your-custom-module**/customer/product/details/common_attributes/common.product-attributes.sku.twig

xim 11-09-2017 03:37 AM

Re: Hiding product weights and inventory quantities
 
https://forum.x-cart.com/showpost.php?p=405434&postcount=2


All times are GMT -8. The time now is 10:38 PM.

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