Customize controller

By default, all S-Cart controller files are located in:

Front-end: "vendor/s-cart/core/src/Front/Controller"
Back-end: "vendor/s-cart/core/src/Admin/Controller"

Since S-Cart version 6.9, you can optionally change the content of conntroller files to your liking.
Specifically:
Step 1:
Create controller files corresponding to the files in the vendor:

For example:
- "S-cart-folder/vendor/s-cart/core/src/Front/Controllers/FileNameFront.php" -> "S-cart-folder/app/Http/Controllers/FileNameFront.php"
- "S-cart-folder/vendor/s-cart/core/src/Admin/Controllers/FileNameAdmin.php" -> "S-cart-folder/app/Admin/Controllers/FileNameAdmin.php"

Attention:
- The location of the controller file must be exactly like the example above
- The file name must be the same as the core file
- Must change the correct namespace, for example

- File core: "SCart\Core\Admin\Controllers" -> File new: "App\Admin\Controllers"
- File core: "SCart\Core\Front\Controllers" -> File new:  "App\Http\Controllers"

You have 2 options to create a new file (*):

- Method 1: Copy the new file content like the core file, just change the namespace (You must copy the full content from the core file)
- Method 2: The new file is extended from the core. Just rewrite the necessary functions to your liking.

(*) We recommend you to use method 2 (extend from old file). This will help you inherit the latest updates from s-cart/core. 

Step 2:
Customize it

Instructional videos:

 

Related topics

Latest Document