Skip to content

Commit 940103a

Browse files
update the ups shipping module in v2.0
1 parent 0bf6e74 commit 940103a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+858
-415
lines changed

CHANGELOG for v1.3.x.md

Lines changed: 0 additions & 7 deletions
This file was deleted.

CHANGELOG for v0.1.x.md renamed to CHANGELOG for v2.0.0.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# CHANGELOG for v0.1.x
1+
# CHANGELOG for v2.0.0
22

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

5-
## **v0.1.0(23 of Feb, 2020)** - *Release*
5+
## **v2.0.0** - *Development*
66

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

LICENSE

Lines changed: 0 additions & 21 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,7 @@ composer dump-autoload
4545
~~~
4646

4747
~~~
48-
php artisan route:cache
49-
~~~
50-
51-
~~~
52-
php artisan config:clear
48+
php artisan optimize:clear
5349
~~~
5450

5551
~~~

package.json

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/node_modules
2+
/npm-debug.log
3+
/package-lock.json
Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
{
2-
"name": "bagisto/bagisto-ups-shipping",
2+
"name": "bagisto/laravel-ups",
33
"license": "MIT",
44
"authors": [
55
{
6-
"name": "Naresh Verma",
7-
"email": "naresh.verma327@webkul.com"
8-
}, {
9-
"name": "Vivek Sharma",
10-
"email": "viveksh047@webkul.com"
6+
"name": "Bagisto",
7+
"email": "support@bagisto.com"
118
}
129
],
13-
"require": {
14-
"konekt/concord": "^1.2"
15-
},
10+
"require": {},
1611
"autoload": {
1712
"psr-4": {
1813
"Webkul\\UpsShipping\\": "src/"
@@ -27,4 +22,4 @@
2722
}
2823
},
2924
"minimum-stability": "dev"
30-
}
25+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"private": true,
3+
"scripts": {
4+
"dev": "vite",
5+
"build": "vite build"
6+
},
7+
"devDependencies": {
8+
"axios": "^1.4.0",
9+
"laravel-vite-plugin": "^0.7.2",
10+
"postcss": "^8.4.23",
11+
"vite": "^4.0.0"
12+
}
13+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
plugins: {
3+
tailwindcss: {},
4+
autoprefixer: {},
5+
},
6+
};

src/Carriers/Ups.php renamed to packages/Webkul/UpsShipping/src/Carriers/Ups.php

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,37 @@
22

33
namespace Webkul\UpsShipping\Carriers;
44

5+
use Webkul\Checkout\Facades\Cart;
56
use Webkul\Checkout\Models\CartShippingRate;
67
use Webkul\Shipping\Carriers\AbstractShipping;
78
use Webkul\UpsShipping\Helpers\ShippingMethodHelper;
8-
use Webkul\Checkout\Facades\Cart;
99

1010
class Ups extends AbstractShipping
1111
{
12+
/**
13+
* The shipping method helper instance.
14+
*
15+
* @var \Webkul\UpsShipping\Helpers\ShippingMethodHelper $shippingMethodHelper
16+
* @return void
17+
*/
18+
public function __construct(
19+
protected ShippingMethodHelper $shippingMethodHelper,
20+
)
21+
{
22+
}
23+
1224
/**
1325
* Payment method code
1426
*
1527
* @var string
1628
*/
17-
protected $code = 'ups';
29+
protected $code = 'ups';
1830

1931
/**
20-
* Returns rate for ups
32+
* Calculate shipping rates.
2133
*
22-
* @return array
23-
*/
34+
* @return array|false
35+
*/
2436
public function calculate()
2537
{
2638
if (! $this->isAvailable()) {
@@ -30,34 +42,37 @@ public function calculate()
3042
$shippingMethods = $rates = [];
3143

3244
$cart = Cart::getCart();
33-
45+
3446
$address = $cart->shipping_address;
35-
36-
$cartProducts = app(ShippingMethodHelper::class)->getAllCartProducts($address);
47+
48+
$data = $this->shippingMethodHelper->getAllCartProducts($address);
3749

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

40-
if (isset($cartProducts)) {
41-
foreach ($cartProducts as $key => $fedexServices) {
52+
if (! $this->isAvailable())
53+
return false;
54+
55+
if (isset ($data) && $data == true) {
56+
foreach ($data as $key => $fedexServices) {
4257
$rate = $totalShippingCost = 0;
43-
$upsMethod = $methodCode = $key;
58+
59+
$upsMethod = $methodCode = $key;
4460

4561
foreach ($fedexServices as $methods => $upsRate) {
4662
$rate += $upsRate['rate'] * $upsRate['itemQuantity'];
47-
4863
$sellerId = $upsRate['marketplace_seller_id'];
4964

50-
$itemShippingCost = $upsRate['rate'] * $upsRate['itemQuantity'];
65+
$itemShippingCost = $upsRate['rate'] * $upsRate['itemQuantity'];
5166

5267
$rates[$key][$sellerId] = [
5368
'amount' => core()->convertPrice($itemShippingCost),
54-
'base_amount' => $itemShippingCost,
69+
'base_amount' => $itemShippingCost
5570
];
5671

57-
if (isset($rates[$key][$sellerId])) {
72+
if (isset ($rates[$key][$sellerId])) {
5873
$rates[$key][$sellerId] = [
5974
'amount' => core()->convertPrice($rates[$key][$sellerId]['amount'] + $itemShippingCost),
60-
'base_amount' => $rates[$key][$sellerId]['base_amount'] + $itemShippingCost,
75+
'base_amount' => $rates[$key][$sellerId]['base_amount'] + $itemShippingCost
6176
];
6277
}
6378

@@ -67,26 +82,33 @@ public function calculate()
6782
$object = new CartShippingRate;
6883

6984
$object->carrier = 'mpups';
85+
7086
$object->carrier_title = $this->getConfigData('title');
87+
7188
$object->method = 'mpups_' . '' . $methodCode;
89+
7290
$object->method_title = $this->getConfigData('title');
91+
7392
$object->method_description = $upsMethod;
93+
7494
$object->price = core()->convertPrice($totalShippingCost);
95+
7596
$object->base_price = $totalShippingCost;
7697

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

79100
if (! is_array($marketplaceShipping)) {
80101
$marketplaceShippingRates['mpupsshipping'] = ['mpupsshipping' => $rates];
81102
session()->put('marketplace_shipping_rates', $marketplaceShippingRates);
103+
82104
} else {
83105
$marketplaceFedexShipping = ['mpupshipping' => $rates];
84106
}
85107

86108
array_push($shippingMethods, $object);
87109
}
88110

89-
if (isset($marketplaceFedexShipping)) {
111+
if (isset ($marketplaceFedexShipping)) {
90112
session()->put('marketplace_shipping_rates.mpupshipping', $marketplaceFedexShipping);
91113
}
92114

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
return [
4+
'ups' => [
5+
'code' => 'ups',
6+
'title' => 'UPS Shipping',
7+
'description' => 'UPS Shipping',
8+
'active' => true,
9+
'class' => 'Webkul\UpsShipping\Carriers\Ups',
10+
],
11+
];

0 commit comments

Comments
 (0)