Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the Bagisto UPS Shipping module in v2.0 #4

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions CHANGELOG for v1.3.x.md

This file was deleted.

15 changes: 15 additions & 0 deletions CHANGELOG for v2.0.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# CHANGELOG for v2.0.0

#### This changelog consists the bug & security fixes and new features being included in the releases listed below.

## **v2.0.0** - *Development*

* [feature] The admin can enable or disable the usps Shipping method.

* [feature] The admin can set the ups shipping method name that will be shown from the front side.

* [feature] The admin can define the allowed methods and weight units.

* [feature] The admin can set packaging type and drop off type.

* [feature] Dynamic shipping method for freight calculation.
21 changes: 0 additions & 21 deletions LICENSE

This file was deleted.

60 changes: 39 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,57 @@
# Introduction
### 1. Introduction:

Bagisto UPS Shipping add-on provides UPS Shipping methods for shipping the product. By using this, you can provide UPS (United Parcel Service) shipping.
UPS Shipping module provides UPS Shipping methods for shipping the product. By using this, you can provide UPS (United Parcel Service) shipping. UPS is widely acknowledged as a world-class company and now it is with the Bagisto.
This module works with the Bagisto core Package. To use this module you must have installed Bagisto.

It packs in lots of demanding features that allows your business to scale in no time:

- The admin can enable or disable the UPS Shipping method.
* The admin can enable or disable the UPS Shipping method.

- The admin can set the UPS shipping method name that will be shown from the front side.
* The admin can set the UPS shipping method name that will be shown from the front side.

- The admin can define the allowed methods and weight units.
* The admin can define the allowed methods and weight units.

- Dynamic shipping method for freight calculation.
* Dynamic shipping method for freight calculation.

- Tax rate can be calculated based on UPS shipping
### 2. Requirements:

## Requirements:
* **Bagisto**: v2.0.0

- **Bagisto**: v1.3.3
### 3. Installation:

## Installation :
- Run the following command
```
* Run the following command
~~~
composer require bagisto/bagisto-ups-shipping
```
~~~

- Run these commands below to complete the setup
```
* Unzip the respective extension zip and then merge "packages" folders into project root directory.
* Change the module name according to the providers like- (bagisto-ups-shipping) to (UpsShipping)
* Goto config/app.php file and add following line under 'providers'

~~~
Webkul\UpsShipping\Providers\UpsShippingServiceProvider::class
~~~

* Goto composer.json file and add following line under 'psr-4'

~~~
"Webkul\\UpsShipping\\": "packages/Webkul/UpsShipping/src"
~~~

* Run these commands below to complete the setup

~~~
composer dump-autoload
```
~~~

~~~
php artisan optimize:clear
~~~

```
php artisan route:cache
php artisan optimize
~~~
php artisan vendor:publish
```

-> Press 0 and then press enter to publish all assets and configurations.
~~~

> now execute the project on your specified domain.
> now execute the project on your specified domain.
3 changes: 3 additions & 0 deletions packages/Webkul/UpsShipping/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/node_modules
/npm-debug.log
/package-lock.json
13 changes: 4 additions & 9 deletions composer.json → packages/Webkul/UpsShipping/composer.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
{
"name": "bagisto/bagisto-ups-shipping",
"name": "bagisto/laravel-ups",
"license": "MIT",
"authors": [
{
"name": "Naresh Verma",
"email": "[email protected]"
}, {
"name": "Vivek Sharma",
"email": "[email protected]"
"name": "Bagisto",
"email": "[email protected]"
}
],
"require": {
"konekt/concord": "^1.2"
},
"require": {},
"autoload": {
"psr-4": {
"Webkul\\UpsShipping\\": "src/"
Expand Down
13 changes: 13 additions & 0 deletions packages/Webkul/UpsShipping/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"private": true,
"scripts": {
"dev": "vite",
"build": "vite build"
},
"devDependencies": {
"axios": "^1.4.0",
"laravel-vite-plugin": "^0.7.2",
"postcss": "^8.4.23",
"vite": "^4.0.0"
}
}
6 changes: 6 additions & 0 deletions packages/Webkul/UpsShipping/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
};
89 changes: 89 additions & 0 deletions packages/Webkul/UpsShipping/src/Carriers/Ups.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?php

namespace Webkul\UpsShipping\Carriers;

use Webkul\Checkout\Facades\Cart;
use Webkul\Checkout\Models\CartShippingRate;
use Webkul\Shipping\Carriers\AbstractShipping;
use Webkul\UpsShipping\Helpers\ShippingMethodHelper;

class Ups extends AbstractShipping
{
/**
* Payment method code
*
* @var string
*/
protected $code = 'ups';

/**
* Calculate shipping rates.
*
* @return array|false
*/
public function calculate()
{
if (! $this->isAvailable()) {
return false;
}

$shippingRates = [];

$cart = Cart::getCart();

$address = $cart->shipping_address;

$shippingMethodHelper = app(ShippingMethodHelper::class);

$cartProductsShippingData = $shippingMethodHelper->getAllCartProducts($address);

if (! $cartProductsShippingData) {
return false;
}

foreach ($cartProductsShippingData as $sellerId => $shippingMethods) {
$totalShippingCost = 0;

$sellerRates = [];

foreach ($shippingMethods as $methodCode => $methodData) {
$itemShippingCost = $methodData['rate'] * $methodData['itemQuantity'];
$marketplaceSellerId = $methodData['marketplace_seller_id'];

$sellerRates[$marketplaceSellerId] = [
'amount' => core()->convertPrice($itemShippingCost),
'base_amount' => $itemShippingCost,
];

$totalShippingCost += $itemShippingCost;
}

$cartShippingRate = new CartShippingRate;

$cartShippingRate->carrier = 'mpups';

$cartShippingRate->carrier_title = $this->getConfigData('title');

$cartShippingRate->method = 'mpups_' . $sellerId;

$cartShippingRate->method_title = $this->getConfigData('title');

$cartShippingRate->method_description = $sellerId;

$cartShippingRate->price = core()->convertPrice($totalShippingCost);

$cartShippingRate->base_price = $totalShippingCost;

$shippingRates[] = $cartShippingRate;

// Store rates in session
$marketplaceShippingRates = session()->get('marketplace_shipping_rates', []);

$marketplaceShippingRates['mpupsshipping'][$sellerId] = $sellerRates;

session()->put('marketplace_shipping_rates', $marketplaceShippingRates);
}

return $shippingRates;
}
}
11 changes: 11 additions & 0 deletions packages/Webkul/UpsShipping/src/Config/carriers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

return [
'ups' => [
'code' => 'ups',
'title' => 'UPS Shipping',
'description' => 'UPS Shipping',
'active' => true,
'class' => 'Webkul\UpsShipping\Carriers\Ups',
],
];
Loading