ms_roistat
Integration with Roystat
Installation
After downloading add-on, its installation is performed using standard CS-Cart tools on the page Administration panel → Add-ons → Manage add-ons → Download and install add-ons(+).
For CS-Cart version over 4.13.1Panel of admin →Add-ons → Manage add-ons → Gear Button → Manual Installation
Click Download, in the window that appears, select the add-onfile, then Upload & Install
When creating, editing and changing orders, as well as their statuses or changing user data, the formatted data is transferred to the Roistat service by calling its API (https://roistat.api-docs.io/v1/obshie-svedeniya)
After registering and creating a new project in the service, you need to find and copy the following data:
1. Meter number
The number is located in the project settings, menu item Counter code.
The number is copied in one line.
2. User API key
The key is located in the user profile settings, API menu item
Click the Show button and copy the API key.
3. Copy the project number.
The project number is indicated in the service header.
- Connect the RoistatAPI add-on in the integration catalog of the Roistat service
This completes the preliminary configuration of the service. As soon as the first transactions get into the system and they are processed (1-2 hours depending on the load on the Roistat service), then the "Project status" section will take the appropriate form:
It will be possible to update the analytic data without waiting in a queue for processing.
The add-on is configured in the CS-Cart administrative panel on the "Manage add-ons" page"
STEP 1.It is necessary to fill in all the fields on the Parameters tab.
After saving the counter ID, API key and project number in the add-on settings, the add-on will check the connection with the Roistat service and display a button that allows you to upload order statuses and existing orders in your store.
If there are data errors, a corresponding message will be displayed
STEP 2. It is required to configure the unloaded fields.
The Roistat system requires 3 required fields to receive applications:
Deal ID, Deal creation date, Deal status IDthese fields are downloaded automatically and do not require any setting on the part of the user.
You can select the rest of the fields for uploading on the Exported fields tab.
Common fields:
Trade name -human-readable name of the transactions of the type "Order No.".Roistat code - visit number.Order amount - transaction amount; used in the key figure Revenue in Roistat.Client id - Client id - client ID in CS-Cart.Cost price- the cost price of the transaction (to work, you need a add-on from RetailFactory Costs and Profits of a store).
Additional fields:
Showcase - the name of the store where the order was made.
The initial data loading takes place in the add-on settings, when you click on the "Upload everything to Roistat" button.
First of all, the statuses of orders from your store will be created and placed in the "In Progress" category.
Attention!
If, while working with the add-on, the button "Upload everything to Roistat" is pressed again, then all order statuses will again be transferred to the "In Progress" category.
After unloading the statuses of orders, all previously created orders will be unloaded, except for orders with the "Incomplete" status. Please note that orders with this status are never processed or uploaded to Roistat!
If you are configuring the add-on for integration with Roistat through MoySklad, then there is no need to fill in the fields "Your API key" and "Project number". In this case, the main configuration is carried out on the side of the Roistat and MoySklad services.
- After creating orders, we add the value from the COOKIE roistat_visit to the ms_roistat field (table ?:orders) in the database created during the installation of the add-on.
- When synchronizing with MoySklad, add the roistat field (roistat_visit code) and showcase (storefront name) to the xml file.
- Roistat with MoySklad is configured and synchronized separately from the add-on.
- After registering and creating a new project in the service, you need to find and copy the following data from your account in the Roistat system.
Counter number
The number is located in the project settings, menu item Counter code.
The number is copied in one line.
- Next, you need to insert the counter code into the corresponding field of the add-on settings.
- Now we have to change the code of the third-party add-on rus_exim_1c.
а. Manual code change.
In the file /app/addons/rus_exim_1c/Tygh/Commerceml/RusEximCommerceml.php add the code fn_set_hook('rus_exim_1c_order_data', $order_data, $order_xml); into the function public function dataOrderToFile($xml, $order_data, $lang_code).
An example of the added code:
public function dataOrderToFile($xml, $order_data, $lang_code)
{
$export_statuses = $this->s_commerceml['exim_1c_export_statuses'];
$cml = $this->cml;
$order_xml = $this->getOrderDataForXml($order_data, $cml);
// new hook for module ms_roistat
fn_set_hook('rus_exim_1c_order_data', $order_data, $order_xml);
if (empty($order_data['firstname'])) {
unset($order_data['firstname']);
......
б. Automatic code addition.
It is possible to automate the process of adding code to a third-party add-on by installing our ms_addon_fixer add-on and applying the Add Hook for Roistat fix in it.
This completes the add-on configuration and you need to configure the MoySklad service.
In your service account, go to the Sales → Buyers' orders tab and click the Settings (gear) button.
In the window that appears, we add two fields, such as string, roistat and showcase.
Further, the connection is configured according to the official instructionshttps://www.cs-cart.ru/docs/4.11.x/user_guide/addons/commerceml/moy_sklad/.
Synchronization of orders occurs according to the configured schedule of the MySklad system.