2.9.2

Fractional Stock

Allows you to sell a certain amount of goods or goods with a floating value. You can sell food products (in grams, kilograms), products sold in packages (boxes, boxes) and other things that have a floating amount

Installation

After downloading the add-on, its installation is performed using standard CS-Cart tools on the page Admin Panel → Add-ons→ Add-ons Management → Download and install the add-on (+).

For CS-Cart version 4.13.1 and higher, the Admin Panel → Add-ons→ Downloaded add-ons → Gear button → Manual installation.

Image

Installing hooks

To work correctly, you need to install hooks according to the instructions. The information is collected in the add-on tab Information.

This operation for adding hooks is relevant for the current version of the v add-on .2.5.13 and later, in future versions, this operation may no longer be necessary.

Image

To display the quantity of the product in the cart, you need to add 3 hooks to the file “fn.cart.php”:

  1. Open the file fn.cart.php (the file will be located at the path: app/functions/fn.cart.php );
  2. In the opened file, find the line with the code (approximately between lines 6057-6062):
    1. if (!empty($product['qty_step']) && $product['qty_step'] > $min_qty) {
              $min_qty = $product['qty_step'];
      
  3. After the found line, insert the code:
    1. fn_set_hook('check_amount_in_stock_min_qty', $product, $min_qty, $product_id);
      
  4. As a result, you should get the following:
    1. if (!empty($product['qty_step']) && $product['qty_step'] > $min_qty) {
              $min_qty = $product['qty_step'];
          }
      
      
          **fn_set_hook('check_amount_in_stock_min_qty', $product, $min_qty, $product_id);**
      
          $cart_amount_changed = false;
      
      Image
  5. Next, find the line with the code in the file (approximately between lines 6522-6524):
    1. $amount = fn_normalize_amount(@$data['amount']);
      
  6. After the found line, insert the code:
    1. fn_set_hook('add_product_to_cart_post_normalize_ammount', $product_id, $amount, $data);
      
  7. As a result, you should get the following:
    1. $amount = fn_normalize_amount(@$data['amount']);
      
      **fn_set_hook('add_product_to_cart_post_normalize_ammount', $product_id, $amount, $data);**
      
      if (!isset($data['extra']['exclude_from_calculate'])) {
      
      Image
  8. Next, find the line with the code in the file (approximately between lines 9340-9342):
    1. $amount = fn_normalize_amount($v['amount']);
      
  9. After the found line, insert the code:
    1. fn_set_hook('update_cart_products_normalize_amount_post', $amount, $v);
      
  10. As a result, you should get the following:
    1. $amount = fn_normalize_amount($v['amount']);
      
      **fn_set_hook('update_cart_products_normalize_amount_post', $amount, $v);**
      
      $v['extra'] = empty($cart['products'][$k]['extra']) ? array() : $cart['products'][$k]['extra'];
      
      Image
  11. Save the changes to the file;
  12. Clear the cache:
    1. In the admin panel, select Administration → Storage → Clear Cache.
      1. Image

To work with commerceml, you need to add a hook to the file “OrderConvertor.php ”:

  1. Open the file OrderConvertor.php (the file will be located along the path: app/addons/commerceml/src/Convertors/OrderConvertor.php);
  2. In the opened file, find the line with the code (approximately between lines 44-46):
    1. $order->id->external_id = $element->getAsString('id');
      
  3. After the found line, insert the code:
    1. fn_set_hook('commerceml_order_convertor_convert_pre', $element, $import_storage, $order);
      
  4. As a result, you should get the following:
    1. $order->id->external_id = $element->getAsString('id');
      
              **fn_set_hook('commerceml_order_convertor_convert_pre', $element, $import_storage, $order);**
      
          foreach ($element->get('products/product', []) as $item) {
      
      Image
  5. Save the changes to the file;
  6. Clear the cache:
    1. In the admin panel, select Administration → Storage → Clear Cache.
      1. Image

Setting

Add-ons Settings (Global Settings)

Go to the section Add-ons → Downloaded add-ons→ Fractional stock→ Settings tab

Basic Settings:

The settings tab is divided into 3 sections, Global settings for products, Global Settings for packages, and Shopping cart settings.

The application of these settings affects all products of the store at once, unless local settings are set for the product (more on this below).

Global settings for products

Use fractional remainder - Enabling this function will allow you to edit the field: Unit of quantity.

Example

Global settings for packages

The product is for sale:

  • Piece by piece - goods are sold in pieces, all goods (unless another setting is selected locally for the product/package sale is enabled) will be sold in a piece or similar form;
  • Packages - goods are sold in packages, you can specify:
    • The quantity of goods in a package is the step of changing the quantity of goods that will be applied to goods sold in packages;
    • Image

Options for displaying the selection of the quantity of the product:

  • Show the number of packages - Display only the counter with the number of packages in the product card and catalog;
Image
  • Show the quantity of goods and packages - Display in the product card and catalog a counter with the number of packages and the number of goods in the package.
Example

Shopping Cart Settings

Quantity display mode on the basket icon - Allows you to select the display option on the basket icon:

  • Number of items - how many types of goods are in the basket;
Image
  • Number of units - how many units of the product are in the basket;
Image
  • Do not display.
Image

In the add-on settings, the Display tab contains settings responsible for displaying units of measurement and methods of sale on the showcase.

Image
  • Display units of measurement in sellers' offers
    • When this function is enabled on the showcase, the seller's offers will display the unit of measurement of the product specified in the global settings of the add-on or the local settings of the product.

Image
  • Display all sales methods on the categories page
    • This and all subsequent settings are responsible for displaying all sales methods on the pages and blocks of your choice.

Image
Example

In the add-on settings, the Information tab displays the instructions for adding hooks described at the beginning of this instruction.

Add-ons Settings (Local Settings)

Go to the section Products → Products → Open the product to set up the fractional stock→ Go to the Add-ons tab → Find the block MS: Fractional Stock.

Image
⚠️
Local product settings have a higher priority and may override global settings for the entire store.

Product Settings

Use a fractional remainder

  • Global Settings:
    • The unit of measurement of quantity from the global settings of the add-on will be used for the product;
    • For the product, you can specify:
      • Step of the quantity selection list;
      • Minimum quantity of goods to order;
      • The maximum quantity for the purchase of one product.
      • ⚠️
        This setting option is suitable for stores where all or most of the products have the same unit of quantity, for example, in grams.
        Example
      • Yes:
        • A fractional remainder will be used forcibly for the product;
        • For the product, you can specify:
          • The unit of measurement of quantity;
          • Step of the quantity selection list;
          • Minimum quantity of goods to order;
          • The maximum quantity for the purchase of one product.
          • ⚠️
            This setting option is suitable for stores where you need to set a fractional quantity sale for certain products.
            Example
          • No:
            • The fractional balance will be forcibly turned off for the product;
            • For the product, you can specify:
              • The unit of measurement of quantity.
              • ⚠️
                This setting option is suitable for stores where only the unit of quantity measurement needs to be set for goods.
                Example

                Packaging Settings

                The product is sold in packages

                • Global Settings:
                  • Global settings for packages will be used for the product;
                  • Fields are not editable for the product:
                    • The quantity of the product in the package;
                    • Options for displaying the selection of the quantity of the product;
                    • ⚠️
                      This option is suitable for stores that sell all products with the same terms of sale.
                      Example
                    • Yes:
                      • For a product, you can set the quantity of the product in the package;
                      • For the product, you can select options for displaying the selection of the quantity of the product;
                        • ⚠️
                          This option is suitable for stores that sell goods with different quantities in a package.
                    • No:
                      • The product is sold in pieces, global settings do not affect the product, local fields are not editable.

                    Mass editing

                    Through updating products in CS-Cart:

  1. Open the Products → Products;
  2. Select the necessary products;
  3. Click Edit Selected;
    1. Image
  4. Select fields to edit;
    1. Image
  5. Click Edit Selected;
  6. Enter new values for the selected fields; Meaning global - Global Settings Y - Yes N - No
    1. Image
  7. Click Save.

Through the export and import of goods:

  1. Open the Administration → Export Data → Products;
  2. Move the following fields from the list of available fields to the exported fields: MS:Allow Fractional Amount MS:Product Amount Step MS:Product minimum order quantity MS:Product maximum order quantity MS:Product Amount Postfix MS:Product Sale Type MS:Show Sale Types These fields will be displayed in a table file for editing fractional remainder settings
    1. Image
  3. Click Export;
  4. Make the necessary changes in the table file and save;
  5. Open the Administration → Data Import → Products section;
  6. Press the + button;
  7. Select a table file;
  8. Go to the next step Matching fields;
  9. Match the fields as shown below:
    1. Image
  10. Click Import.