Hi!
CS-Cart and Multi-Vendor 4.3.5 is coming, and we publish the list of changes for developers.
Common changes
- REST API:
- Carts entity was added;
- Pages entity was added;
- CallRequests entity was added;
- Discussions entity was added;
- HybridAuth library was updated to version 2.4.2;
- GET /api/features/:id will also contain variant images;
- Price list add-on was totally rewritten — Tygh\PriceList\AGenerator, Tygh\PriceList\Pdf, Tygh\PriceList\Xlsxclasses were introduced and XLS Writer library is used;
- The "Trash" category was introduced;
Hook changes
New hooks
- fn_set_hook('session_set_name_before', $account_type, $sess_postfix); — allows to perform actions before setting the session name;
- fn_set_hook('smarty_display_mail', $this, $template, $to_screen, $area, $company_id, $lang_code, $original_lang_code, $result); — actions before processing mail content via Smarty;
- fn_set_hook('sanitize_html', $config_instance, $raw_html); — allows to configure HTMLPurifier before it purifies the given HTML;
- fn_set_hook('create_order_details', $order_id, $cart, $order_details, $extra); — modifies product order details;
- fn_set_hook('create_order_details_post', $order_id, $cart, $order_details, $extra, $popularity); — modifies product popularity;
- fn_set_hook('save_cart_content_pre', $cart, $user_id, $type, $user_type); — actions before storing cart content in a customer's profile;
- fn_set_hook('save_cart_content_post', $cart, $user_id, $type, $user_type); — actions after storing cart content in a customer's profile;
- fn_set_hook('user_session_products_condition', $params, $conditions); — processes user session products condition;
- fn_set_hook('delete_user_cart', $user_ids, $condition, $data); — deletes products from abandoned/live carts;
- fn_set_hook('get_carts', $type_restrictions, $params, $condition, $join, $fields, $group, $array_index_field); — sets getting abandoned/live carts parameters;
- fn_set_hook('get_carts_before_select', $params, $items_per_page, $fields, $join, $condition, $group, $sorting, $limit); — gets abandoned/live carts;
- fn_set_hook('get_carts_post', $carts_list, $params, $user_ids, $items_per_page, $fields, $join, $condition, $group, $sorting, $limit); — actions after getting abandoned/live carts;
- fn_set_hook('get_cart_products', $user_id, $params, $fields, $conditions); — gets products of a particular abandoned or live cart;
- fn_set_hook('get_cart_products_post', $user_id, $params, $cart_products, $fields, $conditions); — actions after getting products of a particular abandoned or live cart;
- fn_set_hook('get_currencies_list_pre', $params, $area, $lang_code); — performs actions before getting the currencies list;
- fn_set_hook('get_currencies_list_before_select', $params, $area, $lang_code, $join, $order_by, $cond);— sets currencies query parameters;
- fn_set_hook('get_currencies_list_post', $params, $area, $lang_code, $currencies); — gets the currencies list;
- fn_set_hook('init_currency_pre', $params, $area); — performs actions before initializing currencies;
- fn_set_hook('init_currency_post', $params, $area, $primary_currency, $secondary_currency); — sets currencies;
- fn_set_hook('auth_routines', $request, $auth, $field, $condition, $user_login); — selects user data;
Changed hooks
fn_set_hook('save_cart', $cart, $user_id, $type); — is now deprecated and will be removed in version 5.x. Use the save_cart_content_post hook instead.
-fn_set_hook('is_cart_empty', $cart, $result); +fn_set_hook('is_cart_empty', $cart, $result, $check_excluded);
Core Functions
Changed Functions
- Tygh\Backend\Storage\ABackend::_generateName() was renamed toTygh\Backend\Storage\ABackend::generateName() and became a public method;
- Tygh\Tools\Url::build(): php -public function build($encode = false) +public function build($encode = false, $puny = false)
-function fn_cart_is_empty($cart) +function fn_cart_is_empty($cart, $check_excluded = true)
-function fn_get_category_data($category_id = 0, $lang_code = CART_LANGUAGE, $field_list = '', $get_main_pair = true, $skip_company_condition = false, $preview = false) +function fn_get_category_data($category_id = 0, $lang_code = CART_LANGUAGE, $field_list = '', $get_main_pair = true, $skip_company_condition = false, $preview = false, $get_full_path = false)
New Functions
- Tygh\Shippings\Shippings::hasEnabledShippings($company_id) — checks if shippings are enabled for the company. Replaces Registry::get('settings.General.disable_shipping') setting, which was removed;
- Tygh\Shippings\Shippings::isFreeShipping($shipping) — checks if shipping is available for usage with the "Free shipping" product option;
- Tygh\Tools\Math class was added — it contains methods commonly used for mathematic operations:
- floorToPrecision($x, $precision) — floors the given number to the given precision;
- ceilToPrecision($x, $precision) — ceils the given number to the given precision;
- floor($x) - floor() PHP function replacement that doesn't return floats like 1.999999...; - Tygh\Tools\SecurityHelper::generateRandomString() — generates a random string;
- Tygh\Tools\Url::normalizeEmail($email) — normalizes an email address and punycodes it;
- fn_user_session_products_condition($params = array()) — gets an SQL condition to manipulate with the?:user_session_products table;
- fn_delete_user_cart($user_ids, $data = '') — deletes products from abandoned/live carts;
- fn_get_carts($params, $items_per_page = 0) — gets abandoned/live carts;
- fn_get_cart_products($user_id, $params = array()) — gets products of a particular abandoned or live cart;
- fn_get_filter_is_numeric_slider($filter_data) — checks if the given filter appears as a numeric slider;
- fn_create_trash_category($company_id) — creates the category used for trash;
- fn_get_trash_category($company_id) — returns identifier of the category used for trash;
- fn_is_trash_category($category_id) — checks if the category is used for trash;
- fn_add_product_to_trash($product_id, $trash_category_id) — adds a product to the trash category;
- fn_trash_orphaned_products($category_ids) — moves products that are left without categories in their store to trash;
- fn_empty_trash($trash_category_id) — deletes products from the trash category;
- fn_promotion_generate_bonus_coupon($bonus, $bonus_id, $cart) — generates a bonus coupon for an order;