承接 itemvirtual/ecommerce-cart 相关项目开发

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

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

itemvirtual/ecommerce-cart

最新稳定版本:1.0.1

Composer 安装命令:

composer require itemvirtual/ecommerce-cart

包简介

Shopping cart in Laravel

README 文档

README

Latest Version on Packagist Total Downloads

This is where your description should go. Try and limit it to a paragraph or two, and maybe throw in a mention of what PSRs you support to avoid any confusion with users and contributors.

Installation

Install the package via composer:

composer require itemvirtual/ecommerce-cart

Publish config (with --force option to update)

php artisan vendor:publish --provider="Itemvirtual\EcommerceCart\EcommerceCartServiceProvider" --tag=config

You can change the config values for cart_session_name and taxes_included:

#ECOMMERCE_CART_SESSION_NAME="ecommerceCart"
ECOMMERCE_TAXES_INCLUDED=true
ECOMMERCE_CALCULATE_TOTALS=true

Add EcommerceCart to your config/app aliases array

'EcommerceCart' => Itemvirtual\EcommerceCart\Facades\EcommerceCart::class,

Usage

Use the EcommerceCart Facade

use Itemvirtual\EcommerceCart\Facades\EcommerceCart;

Add products to cart

EcommerceCart::addToCart([
    'id' => $Product->id,
    'title' => $Product->name,
    'price' => floatval($Product->price),
    'tax' => 21.0,
    'amount' => 1,
    'data' => [ // add your custom data here
        'tax_id' => 1
    ]
]);

Increment or decrement amount

EcommerceCart::incrementCartItem($Product->id);
EcommerceCart::decrementCartItem($Product->id);

Remove from cart

EcommerceCart::removeCartItem($Product->id);

Set tax

EcommerceCart::setTax($float);

The tax value is set for each item in the cart. To set a global tax value, use setCustomCartData()
It will not affect the calculation of totals on the cartItem, It only serves as data to calculate your totals.

EcommerceCart::setCustomCartData('tax', floatval($tax));

If you save the tax_id value, you can change it with updateCartItemsDataValue()

EcommerceCart::updateCartItemsDataValue($key, $value);
// EcommerceCart::updateCartItemsDataValue('tax_id', 1);

Set apply tax (p.ex if not European)

EcommerceCart::setApplyTax($boolean);

Get Totals

Custom Total calculations

If you need to calculate your Cart Totals, set ECOMMERCE_CALCULATE_TOTALS to false in your .env file

ECOMMERCE_CALCULATE_TOTALS=false

Create your service and use EcommerceCart::getItems() to get your cart contents

$cartItems = EcommerceCart::getItems();

Total calculations

EcommerceCart::getTotal();
EcommerceCart::getSubtotal();
// return taxes array
EcommerceCart::getTaxTotals();
// return total tax amount
EcommerceCart::getTaxTotalValue();

// Get total without shipping
EcommerceCart::getTotalWithoutShipping();

Shipping

Add Global shipping

$ShippingData = [
    'id' => $Shipping->id,
    'title' => $Shipping->title,
    'value' => $Shipping->value,
    'free_from' => $Shipping->free_from,
];
EcommerceCart::setShipping($ShippingData);

Remove Shipping data

EcommerceCart::removeShipping();

Get Shipping data

EcommerceCart::getShipping();

// Returns an object with 4 or 5 properties
{
  +"id": 3
  +"title": "Europe"
  +"value": 10
  +"free_from": 200
  +"free": true
}

Get Cart Items

$cartItems = EcommerceCart::getItems();

EcommerceCart::hasItems();
EcommerceCart::countItems();

Destroy Cart

EcommerceCart::destroyCart();

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-09-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固