Skip to content

Commit

Permalink
Update the bagisto UPS Shipping module in v2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
antuchaudharyqlo246 committed Jan 4, 2024
1 parent 2f12c0f commit e770f6e
Show file tree
Hide file tree
Showing 30 changed files with 924 additions and 381 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG for v0.1.x.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# CHANGELOG for v0.1.x

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

## **v0.1.0(23 of Feb, 2020)** - *Release*

* [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.
58 changes: 37 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,55 @@
# 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**: v0.1.6 or higher.

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

## Installation :
- Run the following command
```
composer require bagisto/bagisto-ups-shipping
```
* Unzip the respective extension zip and then merge "packages" folders into project root directory.
* Goto config/app.php file and add following line under 'providers'

- Run these commands below to complete the setup
```
~~~
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 route:cache
php artisan optimize
~~~

~~~
php artisan config:clear
~~~

~~~
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.
13 changes: 4 additions & 9 deletions 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
23 changes: 23 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"private": true,
"scripts": {
"dev": "vite",
"build": "vite build"
},
"devDependencies": {
"autoprefixer": "^10.4.14",
"axios": "^1.1.2",
"laravel-vite-plugin": "^0.7.2",
"postcss": "^8.4.23",
"tailwindcss": "^3.3.2",
"vite": "^4.0.0",
"vue": "^3.2.47"
},
"dependencies": {
"@vee-validate/i18n": "^4.9.1",
"@vee-validate/rules": "^4.9.1",
"mitt": "^3.0.0",
"vee-validate": "^4.9.1",
"vue-flatpickr": "^2.3.0"
}
}
126 changes: 73 additions & 53 deletions src/Carriers/Ups.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

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

/**
* Ups Shipping Shipping.
* Ups Shipping.
*
*/
class Ups extends AbstractShipping
Expand All @@ -25,70 +26,89 @@ class Ups extends AbstractShipping
*/
public function calculate()
{
if (! core()->getConfigData('sales.carriers.ups.active'))
$uspsMethod = '';

$shippingMethods = [];

$rates = [];

$shippingHelper = app('Webkul\UpsShipping\Helpers\ShippingMethodHelper');

This comment has been minimized.

Copy link
@VikassWebkul214254

VikassWebkul214254 Jan 4, 2024

import class. dont use like this.


$cart = Cart::getCart();

$address = $cart->shipping_address;

$data = $shippingHelper->getAllCartProducts($address);

$marketplaceShipping = session()->get('marketplace_shipping_rates');

if (! $this->isAvailable())

This comment has been minimized.

Copy link
@VikassWebkul214254

VikassWebkul214254 Jan 4, 2024

use {

return false;

$shippingMethods = [];
$rates = [];
$shippingHelper = app('Webkul\UpsShipping\Helpers\ShippingMethodHelper');
$getCommonServices = app('Webkul\UpsShipping\Repositories\UpsRepository');
$data = $shippingHelper->getAllCartProducts();
$serviceData = $getCommonServices->getCommonMethods($data['response']);

$shippingRate = session()->get('shipping_rates');

if ( isset($data['response']) && $data['response'] && !$data['errorResponse'] && !empty($serviceData) ) {
foreach ($serviceData as $key => $upsServices) {
$rate = 0;
$totalShippingCost = 0;
$upsMethod = $key;
$classId = '';

foreach ($upsServices as $upsRate) {
$classId = $upsRate['classId'];
$rate += $upsRate['rate'] * $upsRate['itemQuantity'];
$itemShippingCost = $upsRate['rate'] * $upsRate['itemQuantity'];

if ( isset($rates[$key]) ) {
$rates[$key] = [
'amount' => core()->convertPrice($rates[$key]['amount'] + $itemShippingCost),
'base_amount' => $rates[$key]['base_amount'] + $itemShippingCost
];
} else {
$rates[$key] = [
'amount' => core()->convertPrice($itemShippingCost),
'base_amount' => $itemShippingCost
];
if (isset ($data) && $data == true)
{

foreach ($data as $key => $fedexServices)
{
$rate = 0;
$totalShippingCost = 0;
$upsMethod = $key;
$methodCode = $key;

foreach ($fedexServices as $methods => $upsRate)
{
$rate += $upsRate['rate'] * $upsRate['itemQuantity'];
$sellerId = $upsRate['marketplace_seller_id'];

$itemShippingCost = $upsRate['rate'] * $upsRate['itemQuantity'];

$rates[$key][$sellerId] = [
'amount' => core()->convertPrice($itemShippingCost),
'base_amount' => $itemShippingCost
];

if (isset ($rates[$key][$sellerId]))
{
$rates[$key][$sellerId] = [
'amount' => core()->convertPrice($rates[$key][$sellerId]['amount'] + $itemShippingCost),
'base_amount' => $rates[$key][$sellerId]['base_amount'] + $itemShippingCost
];
}

$totalShippingCost += $itemShippingCost;
$totalShippingCost += $itemShippingCost;
}

$object = new CartShippingRate;

$object->carrier = 'mpups';
$object->carrier_title = $this->getConfigData('title');
$object->method = 'mpups_' . '' . $methodCode;
$object->method_title = $this->getConfigData('title');
$object->method_description = $upsMethod;

$object->price = core()->convertPrice($totalShippingCost);
$object->base_price = $totalShippingCost;

$marketplaceShippingRates = session()->get('marketplace_shipping_rates');

if (! is_array($marketplaceShipping))
{
$marketplaceShippingRates['mpupsshipping'] = ['mpupsshipping' => $rates];
session()->put('marketplace_shipping_rates', $marketplaceShippingRates);

$object = new CartShippingRate;
$object->carrier = 'ups';
$object->carrier_title = $this->getConfigData('title') . ' (' . $this->getConfigData('description') . ')';
$object->method = 'ups_' . $classId;
$object->method_title = $upsMethod;
$object->method_description = $this->getConfigData('title') . ' (' . $this->getConfigData('description') . ')';
$object->is_calculate_tax = $this->getConfigData('is_calculate_tax');
$object->price = core()->convertPrice($totalShippingCost);
$object->base_price = $totalShippingCost;

$shippingRate = session()->get('shipping_rates');

if (! is_array($shippingRate)) {
$shippingRates['ups'] = $rates;
session()->put('shipping_rates', $shippingRates);
} else {
session()->put('shipping_rates.ups', $rates);
$marketplaceFedexShipping = ['mpupshipping' => $rates];
}

array_push($shippingMethods, $object);
}

if (isset ($marketplaceFedexShipping))
{
session()->put('marketplace_shipping_rates.mpupshipping', $marketplaceFedexShipping);
}

return $shippingMethods;
} else {
return null;
}
}
}
}
Empty file modified src/Config/carriers.php
100644 → 100755
Empty file.
Loading

0 comments on commit e770f6e

Please sign in to comment.