定制 prasanna/bagisto-weight-shipping 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

prasanna/bagisto-weight-shipping

Composer 安装命令:

composer require prasanna/bagisto-weight-shipping

包简介

Weight based shipping package for Bagisto - Calculate shipping costs based on total cart weight

README 文档

README

A comprehensive weight-based shipping package for Bagisto that calculates shipping costs based on the total weight of cart items.

Features

  • Weight-based Calculation: Calculates shipping cost based on total cart weight
  • Flexible Rate Configuration: Support for multiple weight ranges with different rates
  • Admin Configuration: Easy-to-use admin interface for configuring weight ranges
  • Multi-language Support: Supports localization for different languages
  • Channel-based Configuration: Different rates for different sales channels
  • Easy Installation: Install via Composer with automated setup

Requirements

  • Bagisto 2.x
  • PHP 8.2+
  • Laravel 11.x
  • Products must have weight attributes set

Installation

Method 1: Via Composer (Recommended)

composer require prasanna/bagisto-weight-shipping

Method 2: Manual Installation

  1. Download the package to your Bagisto installation:

    git clone https://github.com/prasanna/bagisto-weight-shipping.git packages/prasanna/bagisto-weight-shipping
  2. Add to composer.json (in your Bagisto root):

    {
        "autoload": {
            "psr-4": {
                "Prasanna\\WeightShipping\\": "packages/prasanna/bagisto-weight-shipping/src/"
            }
        }
    }
  3. Update autoloader:

    composer dump-autoload

Setup

After installation, run the setup command:

php artisan weight-shipping:install

This command will:

  • Add weight-based shipping to the carriers configuration
  • Add admin configuration fields
  • Add language translations
  • Clear cache

Configuration

  1. Go to Admin Panel → Configuration → Sales → Shipping Methods
  2. Find "Weight Based Shipping" section
  3. Configure the following settings:

Settings

  • Title: Display name for the shipping method
  • Description: Description shown to customers
  • Weight Ranges: Configure weight ranges and their corresponding rates
  • Status: Enable/disable the shipping method

Weight Ranges Format

Enter weight ranges in the following format:

1:45,5:80,10:120

This means:

  • 0-1kg: ₹45
  • 1-5kg: ₹80
  • 5-10kg: ₹120
  • 10kg+: ₹120 (uses last range price)

Example Configurations

Basic Configuration:

1:45,5:80,10:120

Complex Configuration:

0.5:25,1:45,2:60,5:100,10:150,20:250

Usage

For Customers

  1. Add products to cart (products must have weight set)
  2. Go to checkout
  3. Select shipping address
  4. Choose "Weight Based Shipping" from available shipping methods
  5. Complete checkout

For Admins

  1. Set product weights in product management
  2. Configure weight ranges in shipping settings
  3. Enable the shipping method
  4. Monitor and adjust rates as needed

How It Works

Weight Calculation

  1. System calculates total weight of all cart items
  2. For each item: item_weight × quantity
  3. Total weight = Sum of all item weights

Rate Calculation

  1. System parses the weight ranges configuration
  2. Finds the appropriate range for the total cart weight
  3. Returns the corresponding shipping rate

Example

Weight Ranges: 1:45,5:80,10:120

  • Cart with 0.5kg total → ₹45 (0-1kg range)
  • Cart with 3kg total → ₹80 (1-5kg range)
  • Cart with 8kg total → ₹120 (5-10kg range)
  • Cart with 15kg total → ₹120 (uses last range)

Troubleshooting

Common Issues

  1. Shipping method not showing

    • Check if the method is enabled in configuration
    • Verify products have weight attributes set
    • Clear cache: php artisan cache:clear
  2. Incorrect rate calculations

    • Verify weight range format is correct
    • Check product weights are set properly
    • Test with different cart combinations
  3. Configuration not appearing

    • Run installation command: php artisan weight-shipping:install
    • Check if service providers are registered
    • Clear config cache: php artisan config:clear

Debug Steps

  1. Check product weights:

    // In tinker
    $product = Product::find(1);
    dd($product->weight);
  2. Check cart total weight:

    // In tinker
    $cart = Cart::getCart();
    // Check individual item weights
    foreach ($cart->items as $item) {
        echo $item->product->name . ': ' . $item->product->weight . 'kg' . PHP_EOL;
    }
  3. Check configuration:

    // In tinker
    dd(core()->getConfigData('sales.carriers.weightbased'));

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

License

This package is open-source software licensed under the MIT License.

Support

For issues and questions:

  • Check the troubleshooting section above
  • Review Bagisto documentation
  • Check Laravel logs for errors
  • Create an issue on GitHub

Changelog

v1.0.0

  • Initial release
  • Basic weight-based shipping calculation
  • Admin configuration interface
  • Multi-language support
  • Automated installation command

Credits

  • Author: Prasanna
  • Based on: Bagisto eCommerce framework
  • Inspired by: WooCommerce weight-based shipping plugins

prasanna/bagisto-weight-shipping 适用场景与选型建议

prasanna/bagisto-weight-shipping 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 07 月 14 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「php」 「ecommerce」 「laravel」 「shipping」 「weight-based」 「bagisto」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 prasanna/bagisto-weight-shipping 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 prasanna/bagisto-weight-shipping 我们能提供哪些服务?
定制开发 / 二次开发

基于 prasanna/bagisto-weight-shipping 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-07-14