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)
-   -   Remove attributes with multiple values from Specification Tab? (https://forum.x-cart.com/showthread.php?t=70396)

Dr. Bogger 11-01-2014 05:45 AM

Remove attributes with multiple values from Specification Tab?
 
Hi Everyone!

How would I go about editing the tabs on the product page, so that it doesn't display attributes that contain multiple values on the "Specification" Tab?

I like to add Attributes for people to select options, such as to allow them to select a "Color", however, I don't want those options to display under the Specification Tab, as it just adds too much clutter.

=================

Also, if ALL the attributes for a product are "multiple", then don't display the Specification Tab at all.

How would I go about doing this?

minfinger 11-03-2014 03:30 AM

Re: Remove attributes with multiple values from Specification Tab?
 
Bogger, I would like to know how to do this as well. My problem is that we have almost 10 Attributes or Product Variants per product. IMO the Specs Tab is useless anyway, I'd much rather understand how to turn it off.

tony_sologubov 11-03-2014 04:34 AM

Re: Remove attributes with multiple values from Specification Tab?
 
Hi guys!

Do I understand you correctly that you simply want to hide all attributes that have multiple values from displaying in the Specification tab?

Tony.

minfinger 11-03-2014 04:48 AM

Re: Remove attributes with multiple values from Specification Tab?
 
Personally, I'd like to get rid of the Specifications Tab all together. If all it does is list the Product options over again that are right above it, I see no value in it cluttering up the customer experience. I think Bogger might be looking for a more specific option.

Dr. Bogger 11-03-2014 07:16 AM

Re: Remove attributes with multiple values from Specification Tab?
 
Either method will work for me, however, the specifications tab might be useful down the road if you ever wanted to use the "Product Filter" module, so that was why I was looking to remove just the attributes that have "multiple" values, which would still allow for future plans to use other modules.

Attributes with single values are not gonna show up as a "Select Box/Option" anyways, so it's pointless to remove the tab all together, as it would be hidden automatically if there are no "single value" attributes.

Tony, You are understanding me correctly. Is there a way I could do this?

minfinger 11-03-2014 07:19 AM

Re: Remove attributes with multiple values from Specification Tab?
 
I'll agree with that, if there's some way to hide all or Multiples, maybe that's the better road, instead of removing it all together.

Dr. Bogger 11-03-2014 08:43 AM

Re: Remove attributes with multiple values from Specification Tab?
 
Tony, any ideas?

Dr. Bogger 11-07-2014 08:24 AM

Re: Remove attributes with multiple values from Specification Tab?
 
Does anyone know how to do this?

Dr. Bogger 11-10-2014 11:16 AM

Re: Remove attributes with multiple values from Specification Tab?
 
Somebody? Anybody?

tony_sologubov 11-11-2014 07:05 AM

Re: Remove attributes with multiple values from Specification Tab?
 
Hi guys!

Sorry for my late reply.

OK, let us start with a simple solution: removal of entire Specification tab. You can apply it as follows:
1) Create a simple module: http://kb.x-cart.com/display/XDD/Step+1+-+creating+simplest+module
2) In this module decorate the defineTabs() method of the \XLite\View\Product\Details\Customer\Page\APage class and define it like this:

PHP Code:

protected function defineTabs()
    {
        
$list = array();

        
$this->defineDescriptionTab($list);

        return 
$list;
    } 


Articles that will help you are here:
http://kb.x-cart.com/display/XDD/X-Cart+classes+structure+and+namespaces
http://kb.x-cart.com/display/XDD/Step+3+-+applying+logic+changes

Please, let me know if it helps.

Tony.

SignTorch 11-17-2014 04:47 PM

Re: Remove attributes with multiple values from Specification Tab?
 
Here's a way I found to hide product specific attributes that are not in a group

In my case I had several global attributes to display

and when I added 2 yes/no product-specific attributes for variants, those attributes display on top with yes/no as the value, which doesn't look right and is unnecessary

as luck would have it, my global attributes were all in a group, and the template that displays attributes has two IF statements to place a <div> around grouped attributes, which can be made into one IF block that only displays grouped attributes,

so that the yes/no attributes do not get displayed because they are not in a group

copy skins\default\en\product\details\parts\attribute.t pl

to skins\custom_skin\default\en\product\details\parts \attribute.tpl

and comment out the first {end} and the second {if:getAttributeGroup()} statements

Code:

{if:getAttributeGroup()}
<li><div class="head-h3">{getTitle()}</div>
  <ul>
{*end:*}
<li FOREACH="getAttrList(),a">
  <div><strong>{a.name}</strong></div>
  <span class="{a.class}">{a.value:nl2br}</span>
</li>
{*if:getAttributeGroup()*}
  </ul>
</li>
{end:}


instead of only hiding attributes that are not grouped, you could probably expand the if statement to hide specific groups of attributes based on the group title in {getTitle()}

minfinger 11-18-2014 04:41 PM

Re: Remove attributes with multiple values from Specification Tab?
 
That did not work for me.

SignTorch 11-18-2014 08:09 PM

Re: Remove attributes with multiple values from Specification Tab?
 
Quote:

Originally Posted by minfinger
That did not work for me.

before applying the custom template change, make sure there is no group title above the attributes to be hidden

http://www.signtorch.com/bin/xcart/attribute-group.jpg

then place a text marker (1234) in the custom template like so

Code:

1234
{if:getAttributeGroup()}
<li><div class="head-h3">{getTitle()}</div>
  <ul>
{*end:*}
<li FOREACH="getAttrList(),a">
  <div><strong>{a.name}</strong></div>
  <span class="{a.class}">{a.value:nl2br}</span>
</li>
{*if:getAttributeGroup()*}
  </ul>
</li>
{end:}


and then you should see the template text markers, but not the ungrouped attributes

http://www.signtorch.com/bin/xcart/attribute-group2.jpg

if you do not see the text markers, then the custom template may not be at the correct path and filename

and make sure the custom skins module is enabled

minfinger 11-19-2014 06:40 PM

Re: Remove attributes with multiple values from Specification Tab?
 
My apologies. Mine are grouped.

SignTorch 11-20-2014 12:56 AM

Re: Remove attributes with multiple values from Specification Tab?
 
Quote:

Originally Posted by minfinger
My apologies. Mine are grouped.


ok, here's a down and dirty way to hide individual attributes based on hard-coded name values

if you need to hide a whole group, title and all, that would be different

in attribute.tpl shown above, add an inline style on the <li tag

Code:

{if:getAttributeGroup()}
<li><div class="head-h3">{getTitle()}</div>
  <ul>
{end:}
<li FOREACH="getAttrList(),a" style="display:{a.hidden}">
  <div><strong>{a.name}</strong></div>
  <span class="{a.class}">{a.value:nl2br}</span>
</li>
{if:getAttributeGroup()}
  </ul>
</li>
{end:}


then put the following code block in a new file

classes\XLite\Module\XC\CustomSkin\View\Product\De tails\Customer\Attributes.php

the code shown hides two of the attributes shown in my screenshots above

adjust the blue text values and number of if statements to match the name and number of attributes you want to hide

the two red statements are what I added to the original Attributes class

Code:

<?php
namespace XLite\Module\XC\CustomSkin\View\Product\Details\Customer;

function isHidden($a)
{
        if($a=="Number of Designs")return("none");
        if($a=="Number of Categories")return("none");
        return "block";       
}

abstract class Attributes extends \XLite\View\Product\Details\Customer\Attributes implements \XLite\Base\IDecorator
{
        public function getAttrList()
    {
        if (!isset($this->attributes)) {
            $this->attributes = array();
            foreach ($this->getAttributesList() as $a) {
                $value = $a->getAttributeValue($this->getProduct(), true);
                $hidden = isHidden($a->getName());
                if (is_array($value)) {
                    $value = implode($a::DELIMITER, $value);
                }
                if (
                    $value
                    && (
                        $a::TYPE_CHECKBOX != $a->getType()
                        || static::t('No') != $value
                    )
                ) {
                    $this->attributes[] = array(
                        'name'  => $a->getName(),
                        'value' => htmlspecialchars($value),
                        'class' => $this->getFieldClass($a, $value),
                        'hidden' => $hidden

                    );
                }
            }
        }

        return $this->attributes;
    }
}


minfinger 12-04-2014 04:32 PM

Re: Remove attributes with multiple values from Specification Tab?
 
I need to know how to get rid Specifications tab all together. My client just said kill it.

SignTorch 12-04-2014 11:25 PM

Re: Remove attributes with multiple values from Specification Tab?
 
you could remove all product attributes

-------

or to hide all tabs and tab content, put this in custom.css (then description uses full container width)

.product-details-tabs .tabs {display:none;}

--------

or an easy way to selectively remove the specifications tab, run this SQL

UPDATE xc_products SET attrSepTab = 0;

then copy

skins/default/en/product/details/parts/common.product-main-attributes.tpl

to custom_skin and comment out the {*<ul> ... </ul>*} tags

that hides the attributes and any group titles on any products where attrSepTab is 0

that way you could show the specifications tab on some products by setting attrSepTabs to not 0 on certain products

---------

to just globally hide the specs tab you could decorate getTabs() in

classes/XLite/View/Product/Details/Customer/Page/APage.php

with something like this (untested)

Code:

if($id!="specification")
$list[$k] = array(
    'index'  => $i,
    'id'    => 'product-details-tab-' . $id,
    'name'  => is_array($data) && !empty($data['name']) ? $data['name'] : $k,
    'weight' => isset($data['weight']) ? $data['weight'] : $i,
);


xgarb 03-17-2016 02:05 AM

Re: Remove attributes with multiple values from Specification Tab?
 
Another approach...

You can remove the tab and replace it with a tab of your own content from the Product object like this:

Code:

abstract class DefineTabShowSpecification extends \XLite\View\Product\Details\Customer\Page\APage implements \XLite\Base\IDecorator
{


    protected function defineTabs()
    {
        $list = parent::defineTabs();
                unset($list['Specification']); //remove default X-cart specification
               
                $tmp = $this->getSpec();
                  if (!empty($tmp)) {  //if the spec field has data...
                $list['Specification'] = array(
                    'list' => 'product.details.page.tab.detailed_spec', //... show it in the specification tab
                );
            }

        return $list;
    }
       
    protected function getSpec(){
                return $this->getProduct()->specification;       
        }
               
}


(also need in skins/default/en/module/DEV-ID/MODULE-NAME/ folder

Code:

{**
 * Product details spec tab
 *
 *
 * @ListChild(list="product.details.page.tab.detailed_spec")
 *}

{product.specification:h}

)


In this case the client wants to add text and images into the Specification tab. I'd previously added this to the Product Info section in admin so product_translations in the database contains a specification column. The code above display the data from this column.


All times are GMT -8. The time now is 09:59 PM.

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