Author Topic: Different descriptions for same product depending on what catagory is viewed?  (Read 1218 times)

TurnTex

  • Beginner
  • *
  • Posts: 25
First, to get the software specifics out there.  I am running J! 3.4.8 and VM 3.0.13 using Virtueplanet Merchant Template.  My php version is 5.6.16.

I building a new website for myself to replace an aging J1.5.26 VM1.1.9 site.  On the new site, I have a product that is applicable to 2 different categories so I have them both assigned in the product categories section.  The problem is even though it is the same product and sku, it is used differently for category A than for category B.  Is it possible to have a description displayed depending on what category the customer is viewing?  In other words, if the customer is viewing category A and clicks on this product, I would like the description to be applicable for using it with other products in Category A.  If they view the product through Category B, I want a different description that is applicable to Category B products.  I really do not want to have 2 different products/skus for the same product because it will make inventory management difficult.

Does anyone have any suggestions to do this?  Thank you in advance for any help you can provide.  I am not a coder so I can't custom code something and was hoping there might be an option I am not thinking of "out of the box".

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 8936
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.4.2
Even if u use another field for prod desc 2 or a custom field you still have to switch which one to use depending on the cat -
and for that IMHO you need to have some code in the template .. detect the catid.. show the correct desc
GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

TurnTex

  • Beginner
  • *
  • Posts: 25
Unfortunately that is over my head, GJC.  Maybe I should contact the template creator to see if he can help me with it?

TurnTex

  • Beginner
  • *
  • Posts: 25
BTW, THANK YOU for your reply, GJC!

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 8936
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.4.2
Once u sort how you will fill-in two descriptions in the admin (custom field or use another field like Internal note) you just need the logic in the template to switch them according to the cat id
GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3955
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Another solution, is to use 2 layout file for product desc, and associate the layout for the product.
See in categorie edition form : Default Product Details Page

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10352
  • VirtueMart Version: 3+

I just did a little with this,

I created a customfield "textarea"
Named it   cat92   (92 for the category id)
Then in my product template
added this

   <?php   
          if (!empty($this->product->customfieldsSorted[cat92]))   {
          $jinput = JFactory::getApplication()->input;
        $ccat = $jinput->getInt('virtuemart_category_id', '0');
   foreach ($this->product->customfieldsSorted[cat92] as $field) {
   $ccheck  = str_replace( 'cat', '', $field->custom_title);
   if ($ccheck==$ccat)   {
   $this->product->product_desc=$field->customfield_value;}
   }
       } ?>

This will display the "textarea" field when the product is in category id 92.

of course this could easily be scale able with a little more logic, technically the code would only work on 1 category per custom field.
J3.9+ VM 3.4.2
Slowest Page Speed Score (88) (Category)
Fastest Page Speed Score (94-96) (productdetails)

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3955
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
WHy changing the code when you have native code to do this ?
Read my answer.
Copy the dafault layout and remove product desc or any field you need to remove.
And Add in this copy of default to render customfield with position YOURPOSITION
Code: [Select]
echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$this->product,'position'=>'YOURPOSITION'));

TurnTex

  • Beginner
  • *
  • Posts: 25
Thank you all for the replies.  Unfortunately, I am not a coder and know just enough about PHP to make changes when I am told what to change or add and where.  If anyone is willing to give me a little more in depth details on how to implement this, it would be greatly appreciated.  If not, I completely understand!

One thing that I wonder about...I am using Virtueplanet Merchant template.  The template creates a tab for the description as well as other custom fields that are set a certain way.  How would either of the options mentioned be affected by that?  Here is a screen shot of what I mean.  If anyone wants to see the site www.pensandbeyond.com.  This is still in development and not publicized yet.  It is on a shared hosting account I use for development.  Once I am done with it, I will move it back to my VPS to replace the old site.


GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 8936
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.4.2
you would need to make the changes within the desc tab area...
GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10352
  • VirtueMart Version: 3+
The template creates a tab for the description as well as other custom fields that are set a certain way.  How would either of the options mentioned be affected by that? 


the code I posted above actually CHANGES the product description
so, no layout changes are made.
It simply switches the product description for the customfield text
J3.9+ VM 3.4.2
Slowest Page Speed Score (88) (Category)
Fastest Page Speed Score (94-96) (productdetails)

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 8936
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.4.2
Quote
you would need to make the changes within the desc tab area...

of course dependent on what solution you go for
GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

TurnTex

  • Beginner
  • *
  • Posts: 25
Folks, than you so much for your help!  I was able to get it implemented and it is fully functional!  I have to give a huge Thank You to Jumbo with Virtueplanet on this.  I am using his Merchant template and he is one of the absolute best template providers I have worked with.  He is willing to help out and did some custom coding for me to implement this.  After posting here, I decided to post on his support forum like I have many times asking if this could be done.  He said it was not possible so I directed him to this thread to get some of your ideas.  He went to work and implemented it for me as I do not have the technical abilities to do this.  All if this was done without him asking for a penny!  (of course I sent him some money anway!).

So, thank you all for the ideas and inspiration to help me get this done and for providing some ideas for Jumbo to work with!  I sincerely appreciate it!

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 8936
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.4.2
Nice to hear and see feedback about users experiences with templaters and coders .. should be encouraged..   :)
GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation