承接 scriptbaker/magento2-ship-out-of-stock-items 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

scriptbaker/magento2-ship-out-of-stock-items

Composer 安装命令:

composer require scriptbaker/magento2-ship-out-of-stock-items

包简介

This Magento 2 module allows the creation of shipments for orders containing items that are out of stock. In default Magento, attempting to create a shipment for an order with out-of-stock items results in the error: "Not all of your products are available in the requested quantity." This module rem

README 文档

README

Overview

The Scriptbaker_ShipOutOfStockItems module for Magento 2 allows the creation of shipments for orders containing items that are out of stock. In default Magento, attempting to create a shipment for an order with out-of-stock items results in the error: "Not all of your products are available in the requested quantity." This module remedies that problem by adjusting the stock quantities to ensure the shipment can be processed.

Features

  • Enables shipment creation for out-of-stock items.
  • Automatically adjusts stock quantities to allow for shipment processing.
  • Seamlessly integrates with Magento's Multi-Source Inventory (MSI) system.

Installation

  1. Download the Module: Download the module package or clone the repository into the app/code/Scriptbaker/ShipOutOfStockItems directory.

  2. Enable the Module:

    bin/magento module:enable Scriptbaker_ShipOutOfStockItems
  3. Run Setup Upgrade:

    bin/magento setup:upgrade
  4. Clear Cache:

    bin/magento cache:clean

Usage

Once the module is installed and enabled, it will automatically adjust stock quantities to allow for the creation of shipments for out-of-stock items. No additional configuration is necessary.

Implementation Details

The module listens to two key events and adjusts the stock quantities accordingly:

  1. sales_order_shipment_save_before:
    • Adjusts stock quantities before the shipment is created to ensure it can be processed without errors.
  2. sales_order_shipment_save_after:
    • Updates stock quantities after the shipment is saved to reflect the accurate inventory levels.

Files Included

  • registration.php: Registers the module with Magento.
  • etc/module.xml: Declares the module and its version.
  • etc/events.xml: Registers the observers for the sales_order_shipment_save_before and sales_order_shipment_save_after events.
  • Observer/AlwaysShipOrder.php: Contains the logic for adjusting stock quantities before shipment creation.
  • Observer/UpdateStockAfterShipment.php: Contains the logic for updating stock quantities after the shipment is saved.

Observer Logic

AlwaysShipOrder

The AlwaysShipOrder observer performs the following actions:

  1. Retrieves all items in the shipment.
  2. For each item, checks the available stock quantity.
  3. If the stock quantity is less than the requested shipment quantity, it adjusts the stock quantity to meet the shipment requirement.
  4. Saves the updated stock quantity using the SourceItemsSaveInterface.

UpdateStockAfterShipment

The UpdateStockAfterShipment observer performs the following actions:

  1. Retrieves all items in the shipment.
  2. Updates the stock quantities after the shipment is saved to reflect accurate inventory levels.
  3. Ensures that the inventory system is up-to-date with the changes caused by the shipment.

Contributing

If you wish to contribute to this module, please fork the repository and submit a pull request with your changes. All contributions are welcome.

Support

If you encounter any issues or have any questions regarding the module, please open an issue on the repository or contact us at [hello@scriptbaker.com].

License

This module is open-source and licensed under the MIT License.

Thank you for using Scriptbaker_ShipOutOfStockItems. We hope it helps improve your Magento 2 experience.

统计信息

  • 总下载量: 9
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2024-05-17