How to use the „My Changes“ Add-on in cs cart

How to use the "My Changes" Add-on in cs cart

The „My Changes“-Addon is used to make PHP, CSS and other core file changes in cs cart. The functionality of this Add-on is similar to a child theme and has many great advantages:

  • Your changes won’t be lost after a new update.
  • You have a centralized place for your changes where you can see your modifications in one place.
  • You can’t break your code in My changes; invalid code is ignored and core functionality is loaded instead.

What you’ll need

    1. CS Cart (shopping cart and multi-vendor both support this feature)
    2. An FTP-Client like FileZilla or your host’s WebFTP
    3. Knowledge of CS Cart file structure

How to use My Changes

Go to your admin dashboard, and find „Add-ons“ in the menu at the very top (Alternatively, go to /admin.php?dispatch=addons.manage). Find The „My Changes“ Add-on in the list and change its status from „Disabled“ to „Active“.

How to use the "My Changes" Add-on in cs cart

Activating this plugin won’t change anything on your site, but it enables the functionality of the plugin.

Next, access your cs cart install directory via FTP. Go to /CS-Cart/app/addons/my_changes/. If this directory doesn’t exist, create it.

This is the directory where you’ll be making your changes from now on. CS Cart will first load its core files, then check this directory. If a file is found, its content will be loaded. Note that this doesn’t unload previously loaded functions. Only functions that you specify will be loaded, leaving the rest of the core functionality untouched.

In order to make changes to a file, you have to copy its subfolders and append .post after the filename (but before the file ending!). The root folder is /app/.

Examples (How to customize vendor.php menu)

Let’s say I want to change menu behavior in the vendor.php backend. First, I would have to find the associated core files. (To better understand cs cart file structure, I recommend browsing their forums.)

In my case the files I need are located in /CS-Cart/app/schemas/menu/. Because I’m making quite some changes to the menu and I’m using multivendor, I need to modify both menu.php and menu_multivendor.php.

Next, I’ll create the same directory in the my_changes folder: /CS-Cart/app/addons/my_changes/schemas/menu/. Since I want to change both files, I will create two new files: menu.post.php and menu_multivendor.post.php.

Note that I don’t have to copy the entire file over to the my_changes subfolder. It’s enough to just include the bits of code that you want changed. As a result, remember that files in my_changes need to function as standalone files. So, if you’re changing a php file, your .post.php file will need to begin with <?php . On a similar note, you also have to specify any namespace that you want to use, even if they’re already specified in the original file.

In my example, I will need data from the cs cart registry: use Tygh\Registry;

From the original file, I can tell that the menu is generated via an array that is saved in $schema. Since I just want to hide some menu points, I can change those arrays to be empty.

if (Registry::get('runtime.company_id')) { $schema['central']['products']['items']['categories'] = array(); }

In the end, don’t forget to return your array: return $schema;

And voila! I have just made changes on my site without messing with my core files.


Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.