Jump to content

Product Specifications


Claudia M
 Share

Recommended Posts

I’m trying to do away with the tabs (using a very custom Foundation skin) and adding all needed information in the product description. As I sell vintage items that I may only have one of – one and gone -  with numerous manufacturers and brands I need to be able to make my specifications unique for each product. I’m having a problem with the product code and stock level.  I want the stock level and product code to automatically update when the item sells or info changes. Anyway to do this with html since I’m using the editor?  Here’s a sample of what I tried.

 

<div class="prod-section-title">Product Specifications ...</div>

<table class="nobord">

               <tbody>

                              <tr>

                                             <td class="prod-spec-title">Product Code:</td>

                                             <td class="prod-spec-txt">{$PRODUCT.product_code}</td>

                              </tr>

                              <tr>

{if $PRODUCT.stock_level}

                                             <td class="prod-spec-title">Stock Level</td>

                                             <td class="prod-spec-txt">{$PRODUCT.stock_level}</td>

                              {/if}

</tr> 

 <tr>

 <td class="prod-spec-title">Manufacturer:</td>

 <td class="prod-spec-txt">OBI</td>

 </tr>

</tbody>

            </table>

 

But this is what it looks like online – it’s showing the code:

 

Product Specifications ...

{if $PRODUCT.stock_level} {/if}

Product Code:    {$PRODUCT.product_code}

Stock Level:        {$PRODUCT.stock_level}

Manufacturer:    OBI

 

Thanks,

Claudia

Link to comment
Share on other sites

Unfortunately, CubeCart is not (yet) coded to parse Smarty syntax within product descriptions.

Yes, CubeCart will offer to parse Smarty syntax when showing a Site Doc. There is a checkbox on the Edit Document, General tab.

No such (current) feature for product or category (or extra Contact Us content) descriptions.

The description content is just a string value to plug into the $description variable.

You will need to edit the actual template. Or use a plugin. Or change the core code. Or use javascript (so that once the page is displaying in the browser, data can be updated).

I think the easiest would be to add the capability to parse Smarty syntax to product and category descriptions.

We can help you with that.

Link to comment
Share on other sites

Thanks for your quick response Brian,

What needs to be done to parse Smarty syntax in product descriptions? Seems alot of people could use this ability.

Please forgive my ignorance on this but would each specification have to be added to the database? I'm trying to avoid that.

Claudia

Edited by Claudia M
Link to comment
Share on other sites

If we go with being able to parse Smarty tags in the Product Description, then we can use whatever data has been given to Smarty prior to the parsing.

So, whatever can now be displayed (price, quantity, name, prod_code, etc) we can (probably) use in the description.

Anything additional will need to be derived from that existing data, or retrieved from the database.

For example: if the prod_code needs amending for display purposes only, meaning CubeCart would not care that it changed, the Smarty syntax might be:

{$PRODUCT.product_code}{if $PRODUCT.stock_level lt 1}_oos{/if}

This makes the Product Code look like FuzzWuzz_oos if it is out of stock. Again, this is only for display purposes.

For custom specifications, like "Suitable for ages:" as the spec name, and "8+" as the value for this spec, you will need a plugin. There are a few extensions available to do this.

Once the plugin gives these new specs to Smarty, the product description (probably) can show it.

I say 'probably' because it depends when CubeCart would parse the description content versus when the plugin hook is fired. Which happens first could be managed.

Link to comment
Share on other sites

If you decide to go manual with this - for future listings - create a template listing with the setup the way you want. Then CLONE that listing for new ones, changing the slugs with the appropriate info. That's what I do with the dirtybutterestates listings.

Here's the Source Code I use for Template1:

<p style="text-align: center;"><span style="font-size:16px;"><strong>Title<br />
<br />
Title<br />
<br />
Title<br />
<br />
<span style="color:#0000ff;">CONDITION</span></strong></span></p>

<p><br />
Introduction<br />
<br />
Description<br />
<br />
Size<br />
<br />
Condition</p>

 

Link to comment
Share on other sites

Thank you so much for sharing.  I have always used something similar in word then copy / paste it to

the editor.

<div class="prod-txt">

Main Description

</div>

 

<div class="prod-section-title">Interesting Facts ...</div>

<div class="prod-spec-txt">

Some items have fun historical facts

</div>

 

Below is the new part I’m adding, catered to each item.

 

<div class="prod-section-title">Product Specifications ...</div>

<table class="nobord">

               <tbody>

       <tr>

 <td class="prod-spec-title">Product Code:</td>

 <td class="prod-spec-txt">PPC119</td>

 </tr>

 <tr>

 <td class="prod-spec-title">Stock Level:</td>

 <td class="prod-spec-txt"><div><a class="prode-txt" href="http://www.ebay.com/itm/havana-gran-hotel-america-brochure/152720008293">Link to eBay listing</a> </div></td>

 </tr>

    <tr>

 <td class="prod-spec-title">Condition:</td>

 <td class="prod-spec-txt">Original</td>

 </tr>

<tr>

 <td class="prod-spec-title">Age:</td>

 <td class="prod-spec-txt">Vintage - 1926</td>

 </tr>

    <tr>

 <td class="prod-spec-title">Item Size:</td>

 <td class="prod-spec-txt">8-1/2W x 11H </td>

 </tr>

    <tr>

 <td class="prod-spec-title">Actual Weight:</td>

 <td class="prod-spec-txt">0.3 oz.</td>

 </tr>

  </tbody>

  </table>

Link to comment
Share on other sites

I was working on a "parse Smarty tags" in the Product Description -- but I knew this would happen:

A Smarty tag would be something like {$PRODUCT.condition}. In order to parse that, the PRODUCT variable would need to have the data assigned to it already. But that hasn't happened yet. CubeCart is still collecting and processing the product's data in order to assign it to PRODUCT.

So, I need to find a hook that happens later in the process of building the final page.

Link to comment
Share on other sites

This is what I have come up with so far:

CubeCart admin, Manage Hooks, Code Snippets tab, click Add Snippet:

Enabled: checked
Unique ID: [email protected]
Execution Order: 10
Description: Send product description through Smarty parser
Trigger: calss.cubecart.display_product
Version: 1.0
Author: https://forums.cubecart.com/topic/52901-product-specifications/
PHP Code:
<?php
  /*********************************************************
   * Hook: class.catalogue.display_product
   *
   * Fetches the product's description and
   * short description. If "Parse Content"
   * is enabled:
   * * Smarty will parse the description
   * * Smarty will parse the short description
   * * If needed, a new short description is derived
   *
   * Be careful! The parsed code must reference
   * data already assigned to targeted Smarty variables
   ********************************************************/

$parse_content = true; // set this until an admin interface is created

  if($parse_content){
    $smartyTemplateVar_PRODUCT = $GLOBALS['smarty']->getTemplateVars('PRODUCT');
    $snippet_smartyparseprod_result = $GLOBALS['db']->select('CubeCart_inventory', false, array('product_id' => $smartyTemplateVar_PRODUCT['product_id']));
    $snippet_smartyparseprod = array('description' => $snippet_smartyparseprod_result[0]['description'], 'description_short' => $snippet_smartyparseprod_result[0]['description_short']);
    $snippet_smartyparseprod['description']       = $GLOBALS['smarty']->fetch('eval:'.$snippet_smartyparseprod['description']);       // Compiles for every instance called
    $snippet_smartyparseprod['description_short'] = $GLOBALS['smarty']->fetch('eval:'.$snippet_smartyparseprod['description_short']); // Compiles for every instance called
    $use_this_to_get_short_description = array('description' => $snippet_smartyparseprod['description'], 'description_short' => ($snippet_smartyparseprod['description_short']?:''));
    $smartyTemplateVar_PRODUCT['description']       = $snippet_smartyparseprod['description'];
    $smartyTemplateVar_PRODUCT['description_short'] = $this->descriptionShort($use_this_to_get_short_description);
    $GLOBALS['smarty']->assign('PRODUCT',$smartyTemplateVar_PRODUCT);
  }

Save the snippet.

To test, edit a product description with this example:

In the description editor - SOURCE mode:

<p>This is the main copy for the product.{if $PRODUCT.product_weight gte 2} HEAVY!!!{else} Easy to carry!{/if}</p>

The editor needs to be SOURCE mode as I do not find a toolbutton that can add "protected" content.

Save. View the product description on the storefront. Then set the product's weight to either higher or lower than 2 (other than what it was). View the description again.

A few things to keep in mind:

The CubeCart programmers has CubeCart processing the data and assigning it to the Smarty variables, then are having Smarty compile the appropriate template. Once compiled, getting different data onto the template is an order of magnitude harder.

The main action of the page requested (product, category, document, login, etc) is finalized first, followed by all the extra stuff (header, footer, sidebars, etc). So, to determine what variables may be available, add {debug} to the end of the particular template.

(I have a suggestion in for CC7 to assign all the data to Smarty, waiting until the last possible moment to render all templates.)

Link to comment
Share on other sites

Hey Brian,

Your code worked great!  Have a question ....  please keep in mind I am not smart in this at all.  I mean at all.  When you say

Be careful! The parsed code must reference
   * data already assigned to targeted Smarty variables

Does that mean I have to have a column in the inventory database.  For example if I want to show the manufacturer's line would I create a coulmn called mfg_line (which I have) and have the code something like this?

{if $PRODUCT.mfg_line}
 <tr>
 <td class="prod-spec-title">{$LANG.products_en.mfg_line}</td>
 <td class="prod-spec-txt">{$PRODUCT.mfg_line}</td>
 </tr>
       {/if}


I don't use the stock manufacturer that comes with CubeCart.

I think I answered my own question.  But Brian please reply just in case. I added this to the bottom of a product description

 <table class="nobord bgw">
               <tbody>
  {if $PRODUCT.product_code}
 <tr>
 <td class="prod-spec-title">{$LANG.products_en.product_code}</td>
 <td class="prod-spec-txt">{$PRODUCT.product_code}</td>
 </tr>
       {/if}

  {if $PRODUCT.item_mfg}
 <tr>
 <td class="prod-spec-title">{$LANG.products_en.item_mfg}</td>
 <td class="prod-spec-txt">{$PRODUCT.item_mfg}</td>
 </tr>
       {/if}
       {if $PRODUCT.mfg_brand}
 <tr>
<td class="prod-spec-title">{$LANG.products_en.mfg_brand}</td>
 <td class="prod-spec-txt">{$PRODUCT.mfg_brand}</td>
 </tr>
       {/if}
{if $PRODUCT.mfg_line}
 <tr>
 <td class="prod-spec-title">{$LANG.products_en.mfg_line}</td>
 <td class="prod-spec-txt">{$PRODUCT.mfg_line}</td>
 </tr>
       {/if}
{if $PRODUCT.mfg_model}
 <tr>
 <td class="prod-spec-title">{$LANG.products_en.mfg_model}</td>
 <td class="prod-spec-txt">{$PRODUCT.mfg_model}</td>
 </tr>
       {/if}

        {if $PRODUCT.stock_level}
 <tr>
 <td class="prod-spec-title">{$LANG.products_en.stock_level}</td>
 <td class="prod-spec-txt">{$PRODUCT.stock_level}</td>
 </tr>
       {/if}
            
              
 {if $PRODUCT.item_age}
 <tr>
 <td class="prod-spec-title">{$LANG.products_en.item_age}</td>
 <td class="prod-spec-txt">{$PRODUCT.item_age}</td>
 </tr>
       {/if}
{if $PRODUCT.box_size}
 <tr>
 <td class="prod-spec-title">{$LANG.products_en.item_box_size}</td>
 <td class="prod-spec-txt">{$PRODUCT.box_size}</td>
 </tr>
       {/if}
              {if $PRODUCT.item_size}
 <tr>
 <td class="prod-spec-title">{$LANG.products_en.item_size}</td>
 <td class="prod-spec-txt">{$PRODUCT.item_size}</td>
 </tr>
       {/if}
            {if $PRODUCT.item_wgt}
 <tr>
 <td class="prod-spec-title-last">{$LANG.products_en.item_actual_wgt}</td>
 <td class="prod-spec-txt-last">{$PRODUCT.item_wgt}</td>
 </tr>
       {/if}

      </tbody>
            </table>


and got this (with some styling):

Product Code: THS993
Item Mfg / Brand: Thomson & Taylor Spice Com
Stock Level: 1
Item Age: Vintage
Item Size: 2-5/8L x 1-1/2W x 5/8H
Edited by Claudia M
Answered my own question
Link to comment
Share on other sites

Just wondering if there is any way to create a database column with a blank "fill out the name as you go".  For example I may need a custom field for a certain item(s) and it would be nice to create the name on an as needed basis.  For example:  Now Item Mfg / Brand   -  add a new one blank column so I can type in, for example, distributor or mfg. location - whatever is need for that product.

Thanks in advance,

Claudia

Link to comment
Share on other sites

I mentioned there are several extensions to do this.

However, any extension (including one I wrote) creates keys that are available for every product. Which is to say, a phrase key for "Suitable for ages:" is available for all products to have appropriate values, such as "8+". If a product is not using this phrase, it won't appear in the output. But it is available when adding/editing a product in admin.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...