Adapt Your Add-ons and Themes to CS-Cart 4.13.1

Common Changes

Changes in Context Menu

A single method for creating context menus was introduced. The method is based on schemas. Check the examples here: app/schemas/context_menu/profiles.php

The context menu schema has the following structure:

[
    'selectable_statuses' => array<string, string>                                                                             // List of statuses for selecting items.
    'items'               => [                                                                                                 // List of context menu items.
        'status'  => [                                                                                                         // Item ID.
            'name'              => ['template' => 'status'],                                                                   // Item name.
            'type'              => GroupItem::class,                                                                           // Item type (ActionItem/GroupItem/ComponentItem).
            'data'              => [                                                                                           // Data to provide to a template. Use $data in the template.
                'menu_item_class' => 'cm-no-hide-input',                                                                       // menu_item_attributes, menu_item_class, action_attributes, action_class - used in common templates.
                ...
            ],
            'items'             => [                                                                                           // List of embedded items in GroupItem.
                'm_activate' => [                                                                                              // Link item.
                    'name'          => [
                        'template' => 'change_to_status',
                        'params'   => [
                            '[status]' => __('active'),
                            ...
                        ],
                    ],
                    'dispatch' => 'profiles.m_activate',                                                                       // Dispatch to which the selected items IDs will be passed. The dispatch is also used to check the item availability for an active user.
                    'position' => 10,                                                                                          // Item position in the list.
                ],
                'actions_divider'   => [                                                                                       // Item divider.
                    'type'     => DividerItem::class,                                                                          // Type of an item embedded to GroupItem (GroupActionItem/ComponentItem/DividerItem). The default item type is GroupActionItem..
                    'position' => 20,
                ],
                'notify_checkboxes' => [                                                                                       // Item with its own template.
                    'type'          => ComponentItem::class,
                    'template'      => 'views/profiles/components/context_menu/notify_checkboxes.tpl',                         // Custom template of ComponentItem.
                    'data_provider' => static function () {                                                                    // Callback function to form the data to provide it to a template. Use $data in the template.
                        return [
                            'param1' => 'value2',
                            ...
                        ];
                    },
                    'position'      => 30,
                ],
                ...
            ],
            'permission_callback' => static function ($request, $auth, $runtime) {                                             // Callback function to check an item availability.
                return !(
                    UserTypes::isVendor($auth['user_type'])
                    && UserTypes::isCustomer($request['user_type'])
                    && fn_check_permissions('profiles', 'm_activate', 'admin', 'POST', ['user_type' => $request['user_type']])
                    && fn_check_permissions('profiles', 'm_disable', 'admin', 'POST', ['user_type' => $request['user_type']])
                );
            },
            'position'            => 20,
        ],
        ...
    ],
]

Core changes

Changed Classes

  1. // Old:
    \XMLDocument
    // New:
    \XMLDocument\XMLDocument
    
  2. // Old:
    \XMLParser
    // New:
    \XMLDocument\XMLParser
    

New Functions

  1. Execute an action in the context of the company specified by its ID:

    fn_execute_as_company(callable $action, $company_id)
    
  2. Get an event dispatcher instance:

    \Tygh\Providers\EventDispatcherProvider::getEventDispatcher()
    
  3. Get a notification settings factory instance:

    \Tygh\Providers\EventDispatcherProvider::getNotificationSettingsFactory()
    
  4. Get a built-in license number of an add-on downloaded from the Marketplace:

    \Tygh\Addons\XmlScheme3::getMarketplaceLicenseNumber()
    

Template Changes

Removed Template Hooks

  1. import_presets:bulk_edit
  2. import_presets:bulk_edit_items
  3. import_presets:bulk_edit_actions
  4. banners:bulk_edit
  5. banners:bulk_edit_items
  6. data_feeds:bulk_edit
  7. data_feeds:bulk_edit_items
  8. em_subscribers:bulk_edit
  9. em_subscribers:bulk_edit_items
  10. reward_points:bulk_edit
  11. reward_points:bulk_edit_items
  12. reward_points:bulk_edit_actions
  13. seo_redirects:bulk_edit
  14. seo_redirects:bulk_edit_items
  15. seo_rules:bulk_edit
  16. seo_rules:bulk_edit_items
  17. seo_rules:context_menu
  18. tags:bulk_edit
  19. tags:bulk_edit_items
  20. tags:bulk_edit_actions
  21. block_manager:bulk_edit
  22. block_manager:bulk_edit_items
  23. block_manager:bulk_edit_actions
  24. cart:bulk_edit
  25. cart:bulk_edit_items
  26. cart:bulk_edit_actions
  27. categories:bulk_edit
  28. categories:bulk_edit_items
  29. companies:bulk_edit_items
  30. countries:bulk_edit
  31. countries:bulk_edit_items
  32. datakeeper:bulk_edit
  33. datakeeper:bulk_edit_items
  34. datakeeper:bulk_edit_actions
  35. destinations:bulk_edit
  36. destinations:bulk_edit_items
  37. documents:bulk_edit
  38. documents:bulk_edit_items
  39. documents:bulk_edit_actions
  40. languages:bulk_edit
  41. languages:bulk_edit_items
  42. languages:bulk_edit_actions
  43. orders:bulk_edit
  44. orders:bulk_edit_items
  45. orders:view_tools_list_for_selected
  46. orders:export_tools_list_for_selected
  47. orders:list_tools_for_selected
  48. pages:bulk_edit
  49. pages:bulk_edit_items
  50. pages:bulk_edit_actions
  51. product_features:bulk_edit
  52. product_features:bulk_edit_items
  53. product_options:bulk_edit
  54. product_options:bulk_edit_items
  55. products:bulk_edit
  56. products:bulk_edit_items
  57. products:bulk_edit_actions
  58. profiles:bulk_edit
  59. profiles:bulk_edit_items
  60. profiles:view_tools_list_for_selected
  61. profiles:export_tools_list_for_selected
  62. profiles:list_tools_for_selected
  63. promotions:bulk_edit_items
  64. shipments:bulk_edit
  65. shipments:bulk_edit_items
  66. shipments:bulk_edit_actions
  67. shippings:bulk_edit
  68. shippings:bulk_edit_items
  69. states:bulk_edit_items
  70. taxes:bulk_edit
  71. taxes:bulk_edit_items
  72. taxes:bulk_edit_actions
  73. usergroups:bulk_edit
  74. usergroups:bulk_edit_items

New Template Hooks

New hooks for the context menu were added (see common/context_menu_wrapper.tpl)

  1. import_presets:context_menu
  2. banners:context_menu
  3. data_feeds:context_menu
  4. em_subscribers:context_menu
  5. reward_points:context_menu
  6. seo_redirects:context_menu
  7. tags:context_menu
  8. block_manager:context_menu
  9. cart:context_menu
  10. categories:context_menu
  11. companies:context_menu
  12. companies_invitations:context_menu
  13. countries:context_menu
  14. datakeeper:context_menu
  15. destinations:context_menu
  16. documents:context_menu
  17. languages:context_menu
  18. languages_translations:context_menu
  19. orders:context_menu
  20. p_subscriptions:context_menu
  21. pages:context_menu
  22. payments:context_menu
  23. payouts:context_menu
  24. product_features:context_menu
  25. product_features_groups:context_menu
  26. product_options:context_menu
  27. product_subscriptions:context_menu
  28. products:context_menu
  29. profile_fields:context_menu
  30. profiles:context_menu
  31. promotions:context_menu
  32. sales_reports_charts:context_menu
  33. shipments:context_menu
  34. shippings:context_menu
  35. snippets:context_menu
  36. states:context_menu
  37. static_data:context_menu
  38. storefronts:context_menu
  39. taxes:context_menu
  40. usergroups:context_menu
  41. access_restrictions:context_menu
  42. buy_together:context_menu
  43. call_requests:context_menu
  44. campaigns:context_menu
  45. common_import_presets:context_menu
  46. gift_certificates:context_menu
  47. hybrid_auth:context_menu
  48. mailing_lists:context_menu
  49. menus:context_menu
  50. newsletters:context_menu
  51. organizations:context_menu
  52. product_filters:context_menu
  53. product_reviews:context_menu
  54. product_variations:context_menu
  55. rma_properties:context_menu
  56. rma_returns:context_menu
  57. seo_rules:context_menu
  58. store_locator:context_menu
  59. subscribers:context_menu
  60. suppliers:context_menu
  61. vendor_communication_threads:context_menu
  62. vendor_plans:context_menu
  63. yml_export_price_lists:context_menu

Hook Changes

Changed Hooks

  1. // Old:
    fn_set_hook('promotion_apply_before_get_promotions', $zone, $data, $auth, $cart_products, $promotions, $applied_promotions);
    // New:
    fn_set_hook('promotion_apply_before_get_promotions', $zone, $data, $auth, $cart_products, $promotions, $applied_promotions, $get_promotions_params);
    
  2. // Old:
    fn_set_hook('get_profile_fields', $location, $select, $condition);
    // New:
    fn_set_hook('get_profile_fields', $location, $select, $condition, $params);
    
  3. // Old:
    fn_set_hook('place_suborders', $cart, $suborder_cart);
    // New:
    fn_set_hook('place_suborders', $cart, $suborder_cart, $key_group);
    
  4. // Old:
    fn_set_hook('update_product_features_value_pre', $product_id, $product_features, $add_new_variant, $lang_code, $params, $category_ids);
    // New:
    fn_set_hook('update_product_features_value_pre', $product_id, $product_features, $add_new_variant, $lang_code, $params, $product_category_ids, $product_categories_paths);
    
  5. // Old:
    fn_set_hook('update_product_features_value_post', $product_id, $product_features, $add_new_variant, $lang_code, $params, $category_ids);
    // New:
    fn_set_hook('update_product_features_value_post', $product_id, $product_features, $add_new_variant, $lang_code, $params, $product_categories_ids);
    

New Hooks

  1. This hook is executed before the review is created. The hook allows you to modify the arguments passed to the method:

    fn_set_hook('product_reviews_create_pre', $product_review_data);
    
  2. This hook is executed after checking if the user is eligible to write a review. The hook allows you to modify the arguments passed to the method:

    fn_set_hook('product_reviews_is_user_eligible_to_write_product_review', $user_id, $product_id, $ip, $need_to_buy_first, $review_ip_check, $result);
    
  3. This hook is executed before getting a simple list of user groups from the database. The hook allows you to modify query parameters:

    fn_set_hook('get_simple_usergroups', $type, $get_default, $lang_code, $where);
    
  4. This hook is executed before getting a promotion data. The hook allows you to modify parameters passed to the method:

    fn_set_hook('get_promotion_data_pre', $promotion_id, $lang_code, $extra_condition);
    
  5. This hook allows you to override “Product availability” export field values:

    fn_set_hook('export_product_availability', $availability, $export_type);
    
  6. This hook is executed after getting user data for creating an order via API request. The hook allows you to modify a cart user data:

    fn_set_hook('api_orders_create_after_get_user_data', $params, $status, $data, $valid_params, $auth, $cart);
    
  7. This hook is executed after a company identifier has been replaced with a new one. The hook allows you to perform additional runtime state manipulations:

    fn_set_hook('execute_as_company_after_set_company_id', $action, $company_id);
    
  8. This hook is executed after a company identifier has been restored. The hook allows you to perform additional runtime state manipulations:

    fn_set_hook('execute_as_company_after_restore_company_id', $action, $company_id);
    
  9. The hook is executed after retrieving information from the database. The hook allows you to modify the data:

    fn_set_hook('shippings_get_shipping_for_test_post', $shipping_id, $service_id, $service_params, $package_info, $lang, $shipping_info);
    
  10. This hook is executed after a list of the file extension mappings to the file type has been formed:

    fn_set_hook('get_ext_mime_types', $key, $types);
    
  11. This hook is executed after access status to checkout was determined. Allows you to change it:

    fn_set_hook('get_access_to_checkout', $cart, $payment_methods, $access);
    
  12. This hook is executed after after company orders fulfillment status has been identified. Allows you to change it’s type:

    fn_set_hook('are_company_orders_fulfilled_by_marketplace', $company_id, $fulfillment_status);
    
  13. This hook is executed at the end of determination of specified shipping sender. Allows you to change shipping sender:

    fn_set_hook('is_shipping_sent_by_marketplace', $shipping, $result).