Jump to content

[SOLVED] PS 1.3.x "Enabler/disabler cart modification" (hide cart and prices from item menu in BO)


Recommended Posts

Hi guys!

I have been stucking my head with a perfect solution for this matter and found lot of people have same problem. There are some solutions to this out there but neither one convinced me or they were for old versions of PS.

I recently found a excellent job on this from a spanish guy named Hans in http://todoprestashop.com/foro/viewtopic.php?f=17&t=434&start=10 but it was only for PS 1.0 and he didn't update the code for PS 1.3.

I have been adapting this solution for PS 1.3 and here are the files to make the modifications. Read carefully the instructions below.




IMPORTANT! ALL CREDITS GOES TO HANS, THIS CODE IS NOT MINE, I ONLY ADAPTED IT TO PS 1.3.1


WARNING! THIS MODIFICATION IS ONLY FOR PS 1.3.1 (AT LEAST I DON'T TESTED IT ON 1.3.2), IF ANYONE WANT TO HELP, ADAPT IT FOR 1.3.2 AND I WILL PUBLISH HERE.






Instructions:
--------------

1) Backup all your bd. <--- VERY IMPORTANT!!!
2) Download the zip below.
3) With phpmyadmin in your database execute this code:

ALTER TABLE `ps_product` ADD `show_cart` TINYINT( 1 ) NOT NULL DEFAULT '1'



this is a new field in your product table:

value 0 --> don't show cart
value 1 --> show cart



4) Now, replace all file from the zip to your shop (BACKUP BEFORE!!!). The files in the zip are in folders to help you to figure out where insert files into your ps directory. Pay attention to "yourthemedirectory" folder and "youradmin" folder".


Note1: Some field names and text are in spanish (sorry, i'm from spain) but you can translate them from PS Translation tool to put the text you want.

Note2: This files are original ps1.3.1. files modified with the code changes. If you ALREADY have others modifications to these files in your PS shop and you don't want to lose them, you can manually copy/paste the code changes from my files to yours. Code changes are marked with "Hans" word, use find/search in your text editor and will see the codes you have to insert in your files.

UPDATE: I updated the zip file for ps 1.3.1 'cause i'm stupid and forgot to include one neccesary file in the zip (product.php for the root folder of your PS installation). I think all of you who have problems was because this.

On the other side i made a update of this modification to work with PS 1.3.2., i have tested it on my server and seems to works perfect. I included the zip file below.

cart-enabler-disabler-PS1.3.1(v2).zip

32161_QCGW2wShoaFRyj18PQAh_t

32162_cd5u99vUQrA27PCma5lD_t

32163_zi9uUaqSaTaei5pncpdV_t

cart-enabler-disabler-PS1.3.2.zip

Link to comment
Share on other sites

Yep, but while its released or not, some people like me need a solution for this. Even when 1.4 is out, not everybody are going to update the first day. We have now 1.3.2 with a lot of bug corrections and few people with 1.3.1 have updated as far i know.

Link to comment
Share on other sites

Thanks Rocky, I'll try this solution ubtil then, hopefully it will resolve the "ask for price" in the cart too.
BTW, I've read your interview in Prestamagazine, great job you do here at forum.
Thanks TassDark for resolving the 0 price issue too.

Link to comment
Share on other sites

  • 2 weeks later...

Solution:
----------


in admin/tabs/AdminProducts.php
in postProcess() function before another elseif:

/* Change object Show Cart status (active, inactive) */ //IAMJM
       elseif (isset($_GET['showcart']) AND Tools::getValue($this->identifier))
       {
           if ($this->tabAccess['edit'] === '1')
           {
               if (Validate::isLoadedObject($object = $this->loadObject()))
               {
                   if ($object->toggleShowCartStatus())
                       Tools::redirectAdmin($currentIndex.'&conf=5'.((($id_category = intval(Tools::getValue('id_category'))) AND Tools::getValue('id_product')) ? '&id;_category='.$id_category : '').'&token;='.$token);
                   else
                       $this->_errors[] = Tools::displayError('an error occurred while updating status');
               }
               else
                   $this->_errors[] = Tools::displayError('an error occurred while updating status for object').' '.$this->table.' '.Tools::displayError('(cannot load object)');
           }
           else
               $this->_errors[] = Tools::displayError('You do not have permission to edit anything here.');
       }//IAMJM



in classes/Product.php

in __construct() function in fieldsDisplay Array change show_cart line to this

'show_cart' => array('title' => $this->l('Show Cart'), 'show_cart' => 'showcart', 'align' => 'center', 'type' => 'bool', 'orderby' => false),



add function

/**
    * Toggle object Show Cart Status in database //IAMJM
    *
    * return boolean Update result
    */
   public function toggleShowCartStatus()
   {
        if (!Validate::isTableOrIdentifier($this->identifier) OR !Validate::isTableOrIdentifier($this->table))
            die(Tools::displayError());

        /* Object must have a variable called 'active' */
        elseif (!key_exists('show_cart', $this))
            die(Tools::displayError());

        /* Update active status on object */
        $this->show_cart = intval(!$this->active);

       /* Change status to active/inactive */
       return Db::getInstance()->Execute('
       UPDATE `'.pSQL(_DB_PREFIX_.$this->table).'`
       SET `show_cart` = !`show_cart`
       WHERE `'.pSQL($this->identifier).'` = '.intval($this->id));
   }

   // <-- IAMJM




in classes/AdminTab.php
in displayListContent() function before elseif (isset($params['position']))

elseif (isset($params['show_cart']) AND isset($tr[$key]))//IAMJM
                       echo 'identifier.'='.$id.'&'.$params['show_cart'].
                       ((($id_category = intval(Tools::getValue('id_category'))) AND Tools::getValue('id_product')) ? '&id;_category='.$id_category : '').'&token;='.($token!=NULL ? $token : $this->token).'">
l('Enabled') : $this->l('Disabled')).'" title="'.($tr[$key] ? $this->l('Enabled') : $this->l('Disabled')).'" />';//IAMJM



So now show_cart status can be change from the list of product in Catalog Tab

Regards,

Jean-Michel

Link to comment
Share on other sites

  • 2 weeks later...

Hi guys,

i have installed this mod and for some reason cant get it to work on version 1.31 here are my steps

SQL: ALTER TABLE `ps_product` ADD `show_cart` TINYINT( 1 ) NOT NULL DEFAULT '1'

then i copied over all the files to the respected folders.
the back end seems to be working when i click the radio button it changes and stays but there is no affect on the product page no matter what the selection is it is always not showing.

also on another note i would like to keep the price and remove from the (qty) down but also tried this and still no luck.

Link to comment
Share on other sites

after further investigating i have noticed that the product list is working in the categories but still a no go on the products page. i have noticed that the code is a little different between the two files

product-list.tpl

{if ($product.show_cart != 0)}



and product.tpl

{if ($show_cart != 0)} 



now you would think these would be the same but when i change to $product.show_cart the whole page goes screwy and still does not work.

anybody have an idea?

Link to comment
Share on other sites

I have figured it out. just posting what i did for anyone else that needs it

on product.tpl the code needs to read

{if $product->show_cart != 0}



and not this

{if ($show_cart != 0)}



sometimes it helps to write it down on the forum to figure it out ;-)

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...
  • 5 weeks later...

Thanks James.

If you can provide us the mod files for PS 1.3.5 i can add them to the main post for the community (with credits to you). Note it has to be original files with only the cart disabler modification, you have to delete any other changes if you did any.

Link to comment
Share on other sites

Thanks James.

If you can provide us the mod files for PS 1.3.5 i can add them to the main post for the community (with credits to you). Note it has to be original files with only the cart disabler modification, you have to delete any other changes if you did any.


I am not a coder :) Please take a look (can diff), don't think I made any change of own. Thanks a lot.

AdminProducts.php

Link to comment
Share on other sites

By the way, I checked ps 1.4, the hide cart/price does not have a Inquiry -> contact form. It either show product is available for sale (show cart) or not for sale (no cart). So I guess I will still need to depend on this Enabler/Disabler cart modification.

Anyone using 1.4 with similar or some other behaviour? I could be wrong in my testing since I am short of time and really depend on this mod.

thanks,
James Tan

Link to comment
Share on other sites

Hey guys,

I've used this modification on one shop and it worked great. However, I have come up with a problem when trying it on another shop. When I add the modified AdminProducts.php file, it works fine, but my product description formatting tools disappear.

Does anyone have any insight into this problem? I'm using 1.3.5 btw.

Link to comment
Share on other sites

  • 2 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...