### CS-Cart Addon Database Installation Query
Source: https://docs.cs-cart.com/latest/developer_guide/addons/scheme/scheme3
Defines a SQL query to be executed during the addon installation process. This example demonstrates creating a simple table for tracking queue IDs. The 'for' attribute can specify when the query should run, defaulting to installation.
```sql
CREATE TABLE `?:addon_test_123456789` (
`queue_id` mediumint NOT NULL auto_increment,
PRIMARY KEY (`queue_id`)
) ENGINE=MyISAM DEFAULT CHARSET=UTF8
```
--------------------------------
### Example Addon.xml File (Scheme 3.0) for CS-Cart Add-ons
Source: https://docs.cs-cart.com/latest/map
This provides an example of an `addon.xml` file using Scheme 3.0 for CS-Cart add-ons. Scheme 3.0 introduces enhancements for defining add-on compatibility and dependencies more precisely. Refer to this for creating modern add-ons.
```xml
my_custom_addon
1.2.3
4.15.1
```
--------------------------------
### Example Addon.xml File Structure for CS-Cart Add-ons
Source: https://docs.cs-cart.com/latest/developer_guide/addons/index
This snippet shows an example of the addon.xml file, which defines the structure and metadata for a CS-Cart add-on. It includes information on compatibility, dependencies, and other essential settings for add-on installation and management.
```xml
my_addon
1.0.0
100
active
my_company
4.10.1
My Awesome Addon
```
--------------------------------
### Customized CS-Cart main.json for Single Installation
Source: https://docs.cs-cart.com/latest/developer_guide/getting_started/server_ansible_playbooks
This is an example of a customized main.json file for a single CS-Cart or Multi-Vendor installation without additional storefronts. It demonstrates how to set specific domain names, database names, users, and passwords. Remember to replace the example values with your actual configuration details.
```json
{
"stores_dir": "/var/www/html",
"stores":
{
"doctorzoid.tk":
{
"cart":
{
"storefronts": []
},
"database":
{
"name": "doctorzoid_tk",
"user": "doctorzoid_tk",
"password": "0NkpV5t9VcUYpKtM"
}
}
}
}
```
--------------------------------
### Add-on Installation: Executing XML Functions
Source: https://docs.cs-cart.com/latest/developer_guide/addons/addon_management
This code demonstrates the execution of functions specified in the `` section of an add-on's `addon.xml` file with the `for="install"` condition. These functions can perform various setup tasks required for the add-on.
```php
fn_run_ addon_functions($addon, "install");
```
--------------------------------
### Run CS-Cart Console Installer
Source: https://docs.cs-cart.com/latest/install/install_via_console
This command initiates the CS-Cart or Multi-Vendor installation process through the console. After navigating to the `_install_` directory and ensuring all configuration and file permissions are set correctly, running this command will launch the standard, non-graphical installation wizard.
```bash
php index.php
```
--------------------------------
### Example File and Directory Permissions Configuration
Source: https://docs.cs-cart.com/latest/upgrade/upgrade_via_console
Illustrates the recommended file and directory permissions for CS-Cart installations to ensure proper operation, especially for upgrades. It details ownership, group memberships, and specific permission modes (e.g., 644 for files, 755 for directories) with exceptions for folders like 'design', 'images', and 'var'.
```text
app (755 dev:dev)
...
functions (755 dev:dev)
...
fn.common.php (644 dev:dev)
fn.control.php (644 dev:dev)
...
design (777 dev:dev)
.htaccess (644 dev:dev)
backend (777 dev:dev)
...
templates (777 dev:dev)
...
views (777 dev:dev)
index.tpl (666 dev:dev)
...
...
...
var (777 dev:dev)
.htaccess (644 dev:dev)
upgrade (777 dev:dev)
...
```
--------------------------------
### CS-Cart API Product Filtering and Sorting Example
Source: https://docs.cs-cart.com/latest/developer_guide/api/entities/products
Demonstrates a GET request to the CS-Cart API to retrieve products, applying filters and sorting. This example targets a specific store and filters products by price, then sorts them by name in ascending order. It assumes the API endpoint and necessary authentication are configured.
```http
GET api/stores/1/products?price_from=10&sort_by=product&sort_order=asc
```
--------------------------------
### Copy Default main.json Configuration
Source: https://docs.cs-cart.com/latest/developer_guide/getting_started/server_ansible_playbooks
This command copies the example advanced.json configuration file to main.json within the ~/playbooks/config/ directory. This creates a template file that you can then modify to suit your specific CS-Cart installation needs. It serves as a starting point for your configuration.
```bash
cp ~/playbooks/config/advanced.json ~/playbooks/config/main.json
```
--------------------------------
### Response Format for Listing CS-Cart Languages
Source: https://docs.cs-cart.com/latest/developer_guide/api/entities/languages
Example JSON response format for the 'List Installed Languages' API endpoint. It includes a 'languages' object containing details for each installed language and a 'params' object for pagination information.
```JSON
{
"languages": {
"en": {
"lang_id": "1",
"lang_code": "en",
"name": "English",
"status": "A",
"country_code": "US",
"direction": "ltr"
},
"ru": {
"lang_id": "2",
"lang_code": "ru",
"name": "Русский",
"status": "A",
"country_code": "RU",
"direction": "ltr"
}
},
"params": {
"items_per_page": "10",
"page": 1,
"total_items": 2
}
}
```
--------------------------------
### CS-Cart Update Log Example
Source: https://docs.cs-cart.com/latest/upgrade/upgrade
This is an example of a log file generated during the CS-Cart update process. It details the sequence of operations, including validator execution, backup procedures, database migrations, and language installations. This log helps diagnose the reasons for update successes or failures.
```log
2015-03-27 12:01:13: Start installation of the "core" upgrade package
2015-03-27 12:01:13: ================================================
2015-03-27 12:01:13: Get all available validators
2015-03-27 12:01:13: Execute "collisions" validator
2015-03-27 12:01:13: Upgrade stopped: Awaiting resolving validation errors: collisions
2015-03-27 12:01:21:
2015-03-27 12:01:56: Start installation of the "core" upgrade package
2015-03-27 12:01:56: ================================================
2015-03-27 12:01:56: Get all available validators
2015-03-27 12:01:56: Execute "collisions" validator
2015-03-27 12:01:56: Execute "permissions" validator
2015-03-27 12:01:56: Execute "restore" validator
2015-03-27 12:01:56: Backup files and Database
2015-03-27 12:01:56: Copy package files
2015-03-27 12:01:56: Run migrations
2015-03-27 12:01:56: Phinx by Rob Morgan - http://phinx.org. version 0.3.7
2015-03-27 12:01:56:
2015-03-27 12:01:56: using config file ./app/Tygh/UpgradeCenter/Migrations/config.migrations.php
2015-03-27 12:01:56: using config parser php
2015-03-27 12:01:56: using migration path /Users/alexions/www/git/work/var/upgrade/packages/core/content/migrations
2015-03-27 12:01:56: using environment development
2015-03-27 12:01:56: using adapter mysql
2015-03-27 12:01:56: using database alexions_staging
2015-03-27 12:01:56:
2015-03-27 12:01:56: == 20150317072105 CoreChangePrivelegeName: migrating
2015-03-27 12:01:56: == 20150317072105 CoreChangePrivelegeName: migrated 0.0034s
2015-03-27 12:01:56:
2015-03-27 12:01:56: All Done. Took 0.1739s
2015-03-27 12:01:56: Install langauges from the upgrade package
2015-03-27 12:01:56: Install the "en" language
2015-03-27 12:01:56: Upgrade completed
```
--------------------------------
### CS-Cart Dispatch Example URLs
Source: https://docs.cs-cart.com/latest/user_guide/look_and_feel/layouts/layout_pages/layout_page_attributes
Provides example URLs demonstrating how the dispatch parameter is used to point to specific pages like the cart contents or the checkout page. These examples clarify the practical application of the dispatch format.
```text
index.php?dispatch=checkout.cart_
```
```text
index.php?dispatch=checkout.checkout_
```
--------------------------------
### Navigate to CS-Cart Directory - Bash
Source: https://docs.cs-cart.com/latest/install/digitalocean
This command navigates the user to the CS-Cart installation directory on the server. It requires the domain name of the store to be substituted in the path.
```bash
cd /var/www/html/[your domain name]
```
--------------------------------
### Download CS-Cart Installation Package - Bash
Source: https://docs.cs-cart.com/latest/install/digitalocean
Downloads the CS-Cart or Multi-Vendor installation package using wget. It specifies the edition ('ultimate' or 'multivendor') and saves the downloaded file with a descriptive name. If wget is not found, it suggests installing it using yum.
```bash
wget "https://www.cs-cart.com/index.php?dispatch=pages.get_trial&page_id=297&edition=ultimate" -O cscart.zip
```
```bash
wget "https://www.cs-cart.com/index.php?dispatch=pages.get_trial&page_id=297&edition=multivendor" -O multi-vendor.zip
```
```bash
yum install wget
```
--------------------------------
### Unzip CS-Cart Installation Package - Bash
Source: https://docs.cs-cart.com/latest/install/digitalocean
Extracts the contents of the downloaded CS-Cart or Multi-Vendor zip file into the current directory. This prepares the files for the installation process.
```bash
unzip cscart.zip
```
```bash
unzip multi-vendor.zip
```
--------------------------------
### Configure CS-Cart Installation Settings (config.php)
Source: https://docs.cs-cart.com/latest/install/install_via_console
This PHP code snippet is part of the `config.php` file within the CS-Cart installation directory. It defines essential settings for the installation process, including default add-ons, administrative credentials, language packs, database connection details, and server configurations. Users need to replace placeholder values with their specific information.
```php
return array(
// Add-on names to be installed
// If empty will be installed only addons included by default
'addons' => array(),
'cart_settings' => array (
'email' => 'admin@example.com',
'password' => 'admin',
'secret_key' => 'YOURVERYSECRETCEY',
'languages' => array (
'en', 'da', 'de', 'es', 'fr', 'el', 'it', 'nl', 'ro', 'ru', 'bg', 'no', 'sl',
),
'main_language' => 'en',
'demo_catalog' => true,
'theme_name' => 'basic',
'license_number' => 'CART-1111-1111-1111-1111'
),
'database_settings' => array(
'host' => 'localhost',
'name' => '%DB_NAME%',
'user' => '%DB_USER%',
'password' => '%DB_PASS%',
'table_prefix' => 'cscart_',
'database_backend' => 'mysqli',
'notify' => false,
'allow_override' => 'Y',
),
'server_settings' => array (
'http_host' => '%HTTP_HOST%',
'http_path' => '',
'https_host' => '%HTTP_HOST%',
'https_path' => '',
'correct_permissions' => true,
),
);
```
--------------------------------
### Connect to Server via SSH
Source: https://docs.cs-cart.com/latest/install/apache
This command initiates an SSH connection to your server. Replace 'username' and 'host' with your actual server credentials. This is a prerequisite for managing your server files and running installation commands.
```bash
ssh username@host
```
--------------------------------
### Example Product JSON Response
Source: https://docs.cs-cart.com/latest/developer_guide/api/entities/products
An example JSON structure representing the detailed information returned when fetching a product via the API. This includes product identifiers, pricing, categories, features, and associated media.
```JSON
{
"product_id": "12",
"product": "100g Pants",
"product_type": "P",
"parent_product_id": "0",
"product_code": "U0012O5AF0",
"status": "A",
"company_id": "1",
"list_price": "31.00",
"amount": "10",
"weight": "0.000",
"length": "0",
"width": "0",
"height": "0",
"shipping_freight": "0.00",
"low_avail_limit": "0",
"timestamp": "1328558400",
"updated_timestamp": "1383893547",
"usergroup_ids": "0",
"is_edp": "N",
"edp_shipping": "N",
"unlimited_download": "N",
"tracking": "B",
"free_shipping": "N",
"zero_price_action": "R",
"is_pbp": "Y",
"is_op": "N",
"is_oper": "N",
"is_returnable": "Y",
"return_period": "10",
"avail_since": "0",
"out_of_stock_actions": "N",
"localization": "",
"min_qty": "0",
"max_qty": "0",
"qty_step": "0",
"list_qty_count": "0",
"tax_ids": "6",
"age_verification": "N",
"age_limit": "0",
"options_type": "P",
"exceptions_type": "F",
"details_layout": "default",
"shipping_params": "a:5:{s:16:\"min_items_in_box\";i:0;s:16:\"max_items_in_box\";i:0;s:10:\"box_length\";i:0;s:9:\"box_width\";i:0;s:10:\"box_height\";i:0;}",
"price": "30.00",
"category_ids": [
224
],
"seo_name": "100g-pants",
"seo_path": "223/224",
"main_category": 224,
"options_type_raw": null,
"exceptions_type_raw": null,
"tracking_raw": null,
"zero_price_action_raw": null,
"min_qty_raw": null,
"max_qty_raw": null,
"qty_step_raw": null,
"list_qty_count_raw": null,
"details_layout_raw": "default",
"variation_features":
[],
"main_pair":
{
"pair_id": "823",
"image_id": "0",
"detailed_id": "879",
"position": "0",
"object_id": "12",
"object_type": "product",
"detailed":
{
"object_id": "12",
"object_type": "product",
"type": "M",
"image_path": "https://example.com/images/detailed/0/173283_0113298267324f438bac97eaf.jpg",
"alt": "",
"image_x": "500",
"image_y": "500",
"http_image_path": "http://example.com/images/detailed/0/173283_0113298267324f438bac97eaf.jpg",
"https_image_path": "https://example.com/images/detailed/0/173283_0113298267324f438bac97eaf.jpg",
"absolute_path": "/srv/projects/example.com/web/images/detailed/0/173283_0113298267324f438bac97eaf.jpg",
"relative_path": "detailed/0/173283_0113298267324f438bac97eaf.jpg",
"is_high_res": false
}
},
"base_price": "30.00",
"selected_options":
[],
"has_options": true,
"product_options":
[],
"list_discount": 1,
"list_discount_prc": "3",
"discounts":
{
"A": 0,
"P": 0
},
"product_features":
{
"18":
{
"feature_id": "18",
"value": "",
"value_int": null,
"variant_id": "86",
"feature_type": "E",
"internal_name": "Brand",
"description": "Brand",
"prefix": "",
"suffix": "",
"variant": "Adidas",
"parent_id": "0",
"display_on_header": "Y",
"display_on_catalog": "N",
"display_on_product": "N",
"feature_code": "",
"purpose": "organize_catalog",
"features_hash": "10-86",
"variants":
{
"86":
{
"value": "",
"value_int": null,
"variant_id": "86",
"variant": "Adidas",
"image_pairs":
{
"pair_id": "875",
"image_id": "1006",
"detailed_id": "0",
"position": "0",
"object_id": "86",
"object_type": "feature_variant",
"icon":
{
"image_path": "https://example.com/images/feature_variant/1/Adidas_Logo.svg.png",
"alt": "",
"image_x": "200",
"image_y": "133",
"http_image_path": "http://example.com/images/feature_variant/1/Adidas_Logo.svg.png",
"https_image_path": "https://example.com/images/feature_variant/1/Adidas_Logo.svg.png",
"absolute_path": "/srv/projects/example.com/web/images/feature_variant/1/Adidas_Logo.svg.png",
"relative_path": "feature_variant/1/Adidas_Logo.svg.png",
"is_high_res": false
}
}
}
}
}
},
"qty_content":
[]
}
```
--------------------------------
### PHPUnit Installation using Composer
Source: https://docs.cs-cart.com/latest/developer_guide/core/coding_standards/php
Provides the command to install PHPUnit and its dependencies using Composer. This is a prerequisite for running tests within the CS-Cart development environment.
```bash
cd /path/to/cart/app/lib
composer install --dev
```
--------------------------------
### XML Product Data Structure Example
Source: https://docs.cs-cart.com/latest/user_guide/manage_products/import_export/advanced_product_import
An example of an XML file structure used for product imports in CS-Cart. This structure defines how product information, such as SKU, item name, stock status, and price, is organized. CS-Cart requires specifying the XML target node to correctly parse product data from such files.
```xml
NY, Green Street
9 am - 5 pm
D00014MK1P
- 65" Class (64.5" Diag.) LED 8000 Series Smart TV
Yes
500
K01502P8VF
- Wildwood City Classic
Yes
300
```
--------------------------------
### addon.xml with Settings Section for CS-Cart Add-on
Source: https://docs.cs-cart.com/latest/developer_guide/addons/tutorials/hello_world
This XML snippet extends the basic addon.xml by introducing a 'settings' section. It defines configurable options for the add-on, such as text input fields and select boxes with predefined choices. These settings are accessible via the CS-Cart admin panel after the add-on is re-installed.
```xml
-
Enter any text
input
Hello World!
-
Pick a value from the list
selectbox
blue
-
Red
-
Green
-
Blue
```
--------------------------------
### Get Language Direction in CS-Cart Template Contexts
Source: https://docs.cs-cart.com/latest/developer_guide/addons/compatibility/adapting_4172_to_4181
These examples demonstrate how to retrieve the language direction using the `getLanguageDirection()` method within various CS-Cart template context classes. This is useful for implementing language-specific UI adjustments.
```php
\Tygh\Template\IContext::getLanguageDirection()
```
```php
\Tygh\Template\Snippet\Table\ItemContext::getLanguageDirection()
```
```php
\Tygh\Template\Mail\Context::getLanguageDirection()
```
```php
\Tygh\Template\Internal\Context::getLanguageDirection()
```
```php
\Tygh\Template\Document\Order\Context::getLanguageDirection()
```
--------------------------------
### Nginx Server Block Configuration (Nginx Config)
Source: https://docs.cs-cart.com/latest/install/nginx
This is a sample Nginx server block configuration. It defines how Nginx should handle requests for a specific domain, including listening ports, server names, and document roots. Remember to replace 'example.com' with your actual domain and adjust paths as necessary.
```nginx
#######################################################################
```
--------------------------------
### Basic addon.xml for CS-Cart Add-on
Source: https://docs.cs-cart.com/latest/developer_guide/addons/tutorials/hello_world
This XML file defines the fundamental attributes for a CS-Cart add-on, including its unique identifier, version, display name, description, and priority. It serves as the core manifest for the add-on.
```xml
hello_world
1.0
Hello World
Say hello to the world
100500
```
--------------------------------
### Run LEMP7 Ansible Playbook for CS-Cart Installation
Source: https://docs.cs-cart.com/latest/developer_guide/getting_started/server_ansible_playbooks
Executes the 'lemp7.yml' Ansible playbook for installing CS-Cart with Nginx, MySQL, and PHP 7.1. Ensure you are in the '~/playbooks/' directory and have a 'config/main.json' file.
```bash
cd ~/playbooks/ && ansible-playbook -e @config/main.json -c local -i inventory_php7 lemp7.yml
```
--------------------------------
### Install nano Text Editor on CentOS
Source: https://docs.cs-cart.com/latest/developer_guide/getting_started/server_ansible_playbooks
This command installs the nano text editor on CentOS systems. Nano is a user-friendly command-line text editor recommended for editing configuration files like main.json. This is a prerequisite for editing the file directly on the server if it's not already installed.
```bash
yum install nano
```
--------------------------------
### XML Structure Scheme Example
Source: https://docs.cs-cart.com/latest/developer_guide/core/schemes
An example of an XML-based scheme. While noted as outdated, it shows the basic structure of an XML file used for defining schemes.
```xml
```
--------------------------------
### Get Specific Vendor - Response Format
Source: https://docs.cs-cart.com/latest/developer_guide/api/entities/vendors
Example JSON response for a successful request to get a specific vendor's details. It includes all the attributes associated with that vendor.
```json
{
"company_id": "1",
"lang_code": "en",
"email": "simtech@example.com",
"company": "Simtech",
"timestamp": "1269610461",
"status": "A",
"seo_name": "simtech",
"seo_path": "",
"average_rating": null,
"company_thread_ids": "1_0"
}
```
--------------------------------
### Method Naming and Visibility Order in PHP
Source: https://docs.cs-cart.com/latest/developer_guide/core/coding_standards/php
This PHP code example illustrates method naming conventions and the recommended order of visibility. Method names start with a lowercase letter and follow camelCase. Private and protected methods do not start with an underscore. The example also shows the typical grouping of methods by visibility: public, then private.
```PHP
class ClassLoader
{
/**
* Creates a new ClassLoader that loads classes of the
* specified namespace.
*
* @param string $include_path Path to namespace
*/
public function __construct($include_path = null)
{
// ...
}
/**
* Gets request method name (GET|POST|PUT|DELETE) from current http request
*
* @return string Request method name
*/
private function getMethodFromRequestHeaders()
{
// ...
}
}
```
--------------------------------
### Add-on Initialization: addon.xml
Source: https://docs.cs-cart.com/latest/developer_guide/addons/tutorials/advanced
Defines the basic structure and installation/uninstallation SQL queries for a CS-Cart add-on. It includes add-on identification, versioning, and database table creation/removal.
```xml
advanced_addon
Advanced Add-on
Advanced Add-on
1.0
100500
active
- DROP TABLE IF EXISTS ?:advanced_addon_data;
-
CREATE TABLE `?:advanced_addon_data` (
`user_id` int(11) unsigned NOT NULL DEFAULT 0,
`categories` text NOT NULL DEFAULT '',
PRIMARY KEY (`user_id`)
) Engine=MyISAM DEFAULT CHARSET UTF8;
- DROP TABLE IF EXISTS ?:advanced_addon_data;
```
--------------------------------
### CS-Cart API Get Product Data using cURL
Source: https://docs.cs-cart.com/latest/developer_guide/api/index
Illustrates how to retrieve data for a specific product using the GET HTTP method and cURL. This example targets the product with ID 1.
```bash
curl --user admin@example.com:APIkey -X GET 'http://example.com/api/products/1'
```
--------------------------------
### Create a Product
Source: https://docs.cs-cart.com/latest/developer_guide/api/entities/products
Create a new product in the system. Supports adding product details, vendor information, and images.
```APIDOC
## POST /api/products/
### Description
Creates a new product in the store. You can provide product details, associate it with a vendor, and upload images.
### Method
POST
### Endpoint
/api/products/
### Request Body
- **product** (object) - Required - The details of the product to be created.
- **name** (string) - Required - The name of the product.
- **description** (string) - Optional - The description of the product.
- **price** (number) - Required - The price of the product.
- **images** (array) - Optional - A list of image URLs for the product.
- **vendor_id** (integer) - Optional - The ID of the vendor if the product is for a specific vendor.
### Request Example
```json
{
"product": {
"name": "New Gadget",
"description": "An amazing new gadget with advanced features.",
"price": 99.99,
"images": [
"http://example.com/gadget1.jpg"
],
"vendor_id": 5
}
}
```
### Response
#### Success Response (201)
- **product_id** (integer) - The ID of the newly created product.
- **message** (string) - A success message.
#### Response Example
```json
{
"product_id": 15,
"message": "Product created successfully."
}
```
```
--------------------------------
### Create Product with Images (JSON)
Source: https://docs.cs-cart.com/latest/developer_guide/api/entities/products
This JSON example illustrates how to create a product with multiple images, including a main image and additional images. It supports images from URLs, absolute file paths, and relative paths from the admin panel.
```json
{
"product": "Product Name",
"category_ids": "166",
"price": "1000",
"image_pairs":
{
"object_type": "product",
"detailed": {
"object_type": "product",
"type": "A",
"absolute_path": "/srv/projects/example.com/images/detailed/additional_image1.jpg", // Absolute filesystem path to the image
"alt": "This is where the alt text for the image goes."
},
{
"object_type": "product",
"detailed": {
"object_type": "product",
"type": "A",
"alt": "This is where the alt text for the image goes.",
"relative_path": "detailed/0/additional_image2.jpg" // Relative filesystem path to the image
}
},
"main_pair": {
"object_type": "product",
"detailed": {
"object_type": "product",
"type": "M",
"image_path": "https://example.com/images/detailed/main_image.jpg", // Valid URL pointing to the image
"alt": "This is where the alt text for the image goes."
}
}
}
```
--------------------------------
### Get a Specific Language
Source: https://docs.cs-cart.com/latest/developer_guide/api/entities/languages
Retrieves the details of a single installed language by its ID.
```APIDOC
## GET /api/languages/{lang_id}/
### Description
Retrieves detailed information about a specific installed language using its unique identifier.
### Method
GET
### Endpoint
/api/languages/{lang_id}/
#### Path Parameters
- **lang_id** (string) - Required - The unique identifier of the language to retrieve.
### Response
#### Success Response (200 OK)
- **lang_id** (string) - The unique identifier of the language.
- **lang_code** (string) - The two-letter language code.
- **name** (string) - The name of the language.
- **status** (string) - The status of the language ('A' for active, 'H' for hidden, 'D' for disabled).
- **country_code** (string) - The ISO code of the country associated with the language.
- **direction** (string) - The text direction ('ltr' for left-to-right, 'rtl' for right-to-left).
#### Response Example
```json
{
"lang_id": "1",
"lang_code": "en",
"name": "English",
"status": "A",
"country_code": "US",
"direction": "ltr"
}
```
#### Error Response (404 Not Found)
Returned if the specified language ID does not exist.
```
--------------------------------
### CS-Cart Database Repair Script URL Example (Root Domain)
Source: https://docs.cs-cart.com/latest/user_guide/database/errors/crashed_table
This is an example of the repair script URL when the CS-Cart store is installed directly at the root domain. It simplifies the URL by omitting the directory part.
```url
http://www.example.com/repair4.php?table=cscart_sessions
```
--------------------------------
### Get Schema Data - PHP Example Usage
Source: https://docs.cs-cart.com/latest/developer_guide/core/schemes
Demonstrates a practical example of calling the `fn_get_schema` function in PHP to obtain menu schema data. This code snippet illustrates how to pass arguments to retrieve specific schema information.
```php
$menu = fn_get_schema('menu', 'menu', 'php');
```
--------------------------------
### List Installed CS-Cart Languages (GET /api/languages/)
Source: https://docs.cs-cart.com/latest/developer_guide/api/entities/languages
Retrieves a list of all installed languages in CS-Cart/Multi-Vendor. Supports pagination to manage the number of results per page and the specific page requested. The response includes language details and pagination parameters.
```HTTP
GET /api/languages/
```
```HTTP
GET /api/languages/?page=2&items_per_page=2
```
--------------------------------
### Example of Assigning Product Data to Templater in CS-Cart (PHP)
Source: https://docs.cs-cart.com/latest/developer_guide/core/controllers/index
This example illustrates assigning product name and description variables to the CS-Cart templater within a 'manage' mode GET request. After execution, '$tpl_product_name' and '$tpl_product_description' will be available in the corresponding template file.
```PHP
if ($mode == 'manage') {
$product_name = 'Product 1';
$product_description = 'Product description';
$view->assign('tpl_product_name', $product_name);
$view->assign('tpl_product_description', $product_description);
}
```
--------------------------------
### Add-on Installation: Executing XML Queries
Source: https://docs.cs-cart.com/latest/developer_guide/addons/addon_management
This snippet shows how SQL queries defined within the `` section of an add-on's `addon.xml` file are executed during the installation process. These queries are essential for setting up the database structure required by the add-on.
```php
fn_run__addon_queries($addon, "install");
```
--------------------------------
### Get Specific CS-Cart Language Details (GET /api/languages//)
Source: https://docs.cs-cart.com/latest/developer_guide/api/entities/languages
Fetches detailed information for a specific installed language using its unique identifier (lang_id). Returns HTTP 200 OK with language details if found, or HTTP 404 Not Found if the language does not exist.
```HTTP
GET /api/languages/1/
```
--------------------------------
### Example Usage: Querying an Additional Database
Source: https://docs.cs-cart.com/latest/developer_guide/core/db/additional_dbs
Demonstrates how to use `db_initiate` and `db_connect_to` to query data from an external database.
```APIDOC
## Example: Querying an Additional Database
### Description
This example shows a practical implementation of connecting to an external database and retrieving data from it using CS-Cart's database functions.
### Method
Combination of `db_initiate`, `db_connect_to`, and `db_get_array`.
### Endpoint
N/A (This is a code example, not a specific endpoint)
### Parameters
See `db_initiate` and `db_connect_to` for parameter details.
### Request Example
```php
'backup',
'table_prefix' => 'cscart'
);
// Initiate connection to the backup database
db_initiate('localhost', 'db_user', 'db_password', 'cscart_backup', $params);
// Switch the connection to the backup database (if not already active)
db_connect_to($params, 'cscart_backup');
// Query data from the 'products' table in the backup database
$data = db_get_array("SELECT * FROM ?:products");
// $data will now contain rows from the 'cscart_products' table of the 'cscart_backup' database
print_r($data);
?>
```
### Response
#### Success Response (200)
The `$data` variable will hold an array of associative arrays, where each inner array represents a row from the `cscart_products` table of the `cscart_backup` database.
#### Response Example
```json
[
{
"product_id": 1,
"product_code": "T1000",
"product": "Example Product",
"price": 19.99
// ... other product fields
}
// ... more product rows
]
```
```
--------------------------------
### Interpreting and Applying DIFF File Changes - XML
Source: https://docs.cs-cart.com/latest/upgrade/apply_diff_file
This snippet demonstrates the content of a DIFF file and the corresponding original and patched XML file. It illustrates how lines starting with '-' indicate removals and lines starting with '+' indicate additions, guiding manual file modifications.
```diff
diff --git a/app/addons/my_changes/addon.xml b/app/addons/my_changes/addon.xml
index efa480f..00981ea 100755
--- a/app/addons/my_changes/addon.xml
+++ b/app/addons/my_changes/addon.xml
@@ -1,9 +1,9 @@
my_changes
- 1.0
- 4294967294
+ 2.0
+ 100500
0
- MULTIVENDOR,ULTIMATE
en
+ active
```
```xml
my_changes
1.0
4294967294
0
MULTIVENDOR,ULTIMATE
en
```
```xml
my_changes
2.0
100500
0
en
active
```
--------------------------------
### Partial Store Backup Command Example
Source: https://docs.cs-cart.com/latest/user_guide/database/backup/backup_via_console
This command demonstrates how to back up specific tables and directories.
```APIDOC
## Partial Store Backup Command Example
### Description
This example command shows how to create a backup that includes a specific database table (`cscart_products`), its data, and selected directories (`var/langs`, `var/attachments`).
### Method
Console Command
### Endpoint
`php /path/to/cart/admin.php`
### Parameters
#### Command Line Arguments
- **--dispatch** (string) - Required - Specifies the action to perform, should be `datakeeper.backup`.
- **--p** - Required - This parameter is necessary for the controller to accept POST parameters.
- **--backup_database** (Y/N) - Required - `Y` to back up the database, `N` otherwise.
- **--backup_files** (Y/N) - Required - `Y` to back up store files, `N` otherwise.
- **--dbdump_tables[]** (string) - Optional - An array of table names to back up. Use `all` for all tables.
- **--dbdump_data** (Y/N) - Optional - `Y` to save data from the database, `N` otherwise. Defaults to `Y` if not specified.
- **--extra_folders[]** (string) - Optional - An array of additional directories to back up relative to the store installation path.
### Request Example
```bash
php /path/to/cart/admin.php --dispatch=datakeeper.backup --p --backup_database=Y --backup_files=Y --dbdump_tables[]=cscart_products --dbdump_data=Y --extra_folders[]=var/langs --extra_folders[]=var/attachments
```
### Response
#### Success Response
Upon successful execution, the command will typically output status messages and indicate the location of the created backup file.
```
--------------------------------
### CS-Cart API Product Sorting by Amount Example
Source: https://docs.cs-cart.com/latest/developer_guide/api/entities/products
Shows a basic GET request to the CS-Cart API to retrieve all products, sorted by their quantity in descending order. This example focuses solely on sorting and assumes no other filters are applied. The API response will be an array of products ordered from highest stock to lowest.
```http
GET api/products?sort_by=amount&sort_order=desc
```
--------------------------------
### Navigate to Add-on Directory
Source: https://docs.cs-cart.com/latest/developer_guide/addons/marketplace/addon_package
Changes the current directory to the location where the add-on files were exported, preparing for the creation of the distribution archive.
```bash
$ cd /path/to/addon_directory
```
--------------------------------
### Multi-Vendor API Product Pagination Example
Source: https://docs.cs-cart.com/latest/developer_guide/api/entities/products
Illustrates a GET request to the Multi-Vendor REST API for retrieving products from a specific vendor. This example paginates the results, requesting a specific page number and the number of items per page. It assumes the API endpoint and vendor ID are correctly specified.
```http
GET /api/vendors/1/products?page=5&items_per_page=20
```
--------------------------------
### POST /api/products (with Images)
Source: https://docs.cs-cart.com/latest/developer_guide/api/entities/products
Creates a product and includes multiple images, specifying main and additional images using image_pairs and main_pair objects.
```APIDOC
## POST /api/products (with Images)
### Description
Creates a product with additional images. Images can be specified via absolute paths, relative paths, or URLs. The `image_pairs` object should precede the `main_pair` object.
### Method
POST
### Endpoint
/api/products
### Parameters
#### Request Body
- **product** (string) - Required - The name of the product.
- **category_ids** (string) - Required - The ID of the main category for the product.
- **price** (string) - Required - The price of the product.
- **image_pairs** (object) - Optional - An array of objects for additional product images.
- **object_type** (string) - Required - Type of object, usually 'product'.
- **detailed** (object) - Required - Details for the image.
- **object_type** (string) - Required - Type of object, usually 'product'.
- **type** (string) - Required - Type of image ('A' for additional).
- **absolute_path** (string) - Optional - Absolute filesystem path to the image.
- **relative_path** (string) - Optional - Relative filesystem path to the image.
- **alt** (string) - Optional - Alt text for the image.
- **main_pair** (object) - Required - Object for the main product image.
- **object_type** (string) - Required - Type of object, usually 'product'.
- **detailed** (object) - Required - Details for the main image.
- **object_type** (string) - Required - Type of object, usually 'product'.
- **type** (string) - Required - Type of image ('M' for main).
- **image_path** (string) - Required - Valid URL pointing to the image.
- **alt** (string) - Optional - Alt text for the image.
### Request Example
```json
{
"product": "Product Name",
"category_ids": "166",
"price": "1000",
"image_pairs": [
{
"object_type": "product",
"detailed": {
"object_type": "product",
"type": "A",
"absolute_path": "/srv/projects/example.com/images/detailed/additional_image1.jpg",
"alt": "This is where the alt text for the image goes."
}
},
{
"object_type": "product",
"detailed": {
"object_type": "product",
"type": "A",
"alt": "This is where the alt text for the image goes.",
"relative_path": "detailed/0/additional_image2.jpg"
}
}
],
"main_pair": {
"object_type": "product",
"detailed": {
"object_type": "product",
"type": "M",
"image_path": "https://example.com/images/detailed/main_image.jpg",
"alt": "This is where the alt text for the image goes."
}
}
}
```
### Response
#### Success Response (201)
- **product_id** (integer) - The ID of the newly created product.
#### Response Example
```json
{
"product_id": 393
}
```
#### Error Response (400)
- The product could not be created due to invalid data or image issues.
```
--------------------------------
### Initialize Database Connection with db_initiate
Source: https://docs.cs-cart.com/latest/developer_guide/core/db/additional_dbs
The `db_initiate` method establishes a connection to a specified database host. It requires host, user, password, and database name. Optional parameters include a local alias (`dbc_name`) and table prefix.
```php
db_initiate($host, $user, $password, $name, $params = array());
// Example:
db_initiate('localhost', 'db_user', 'db_password', 'cscart_backup', $params);
```
--------------------------------
### Class, Interface, and Trait Naming Conventions
Source: https://docs.cs-cart.com/latest/developer_guide/core/coding_standards/php
This example illustrates the naming conventions for classes, interfaces, and traits in PHP. It shows the correct application of CamelCase, starting with an uppercase letter, and demonstrates how acronyms within names should also follow CamelCase rules, using 'Api' and 'Rest' as examples.
```PHP
$a->getApiUrl(), $a = new Rest();, class ApiTest
```