Skip to content

Commit

Permalink
update the ups shipping module in v2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
antuchaudharyqlo246 committed Apr 15, 2024
1 parent 0bf6e74 commit 940103a
Show file tree
Hide file tree
Showing 42 changed files with 858 additions and 415 deletions.
7 changes: 0 additions & 7 deletions CHANGELOG for v1.3.x.md

This file was deleted.

4 changes: 2 additions & 2 deletions CHANGELOG for v0.1.x.md → CHANGELOG for v2.0.0.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# CHANGELOG for v0.1.x
# CHANGELOG for v2.0.0

#### 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*
## **v2.0.0** - *Development*

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

Expand Down
21 changes: 0 additions & 21 deletions LICENSE

This file was deleted.

6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,7 @@ composer dump-autoload
~~~

~~~
php artisan route:cache
~~~

~~~
php artisan config:clear
php artisan optimize:clear
~~~

~~~
Expand Down
23 changes: 0 additions & 23 deletions package.json

This file was deleted.

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
15 changes: 5 additions & 10 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 All @@ -27,4 +22,4 @@
}
},
"minimum-stability": "dev"
}
}
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: {},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,37 @@

namespace Webkul\UpsShipping\Carriers;

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

class Ups extends AbstractShipping
{
/**
* The shipping method helper instance.
*
* @var \Webkul\UpsShipping\Helpers\ShippingMethodHelper $shippingMethodHelper
* @return void
*/
public function __construct(
protected ShippingMethodHelper $shippingMethodHelper,
)
{
}

/**
* Payment method code
*
* @var string
*/
protected $code = 'ups';
protected $code = 'ups';

/**
* Returns rate for ups
* Calculate shipping rates.
*
* @return array
*/
* @return array|false
*/
public function calculate()
{
if (! $this->isAvailable()) {
Expand All @@ -30,34 +42,37 @@ public function calculate()
$shippingMethods = $rates = [];

$cart = Cart::getCart();

$address = $cart->shipping_address;

$cartProducts = app(ShippingMethodHelper::class)->getAllCartProducts($address);
$data = $this->shippingMethodHelper->getAllCartProducts($address);

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

if (isset($cartProducts)) {
foreach ($cartProducts as $key => $fedexServices) {
if (! $this->isAvailable())

This comment has been minimized.

Copy link
@VikassWebkul214254

VikassWebkul214254 Apr 16, 2024

curly breakers missing.

return false;

if (isset ($data) && $data == true) {

This comment has been minimized.

Copy link
@VikassWebkul214254

VikassWebkul214254 Apr 16, 2024

break the statement.

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

$upsMethod = $methodCode = $key;

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

$sellerId = $upsRate['marketplace_seller_id'];

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

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

This comment has been minimized.

Copy link
@VikassWebkul214254

VikassWebkul214254 Apr 16, 2024

comma missing

];

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

This comment has been minimized.

Copy link
@VikassWebkul214254

VikassWebkul214254 Apr 16, 2024

comma missing

];
}

Expand All @@ -67,26 +82,33 @@ public function calculate()
$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);

} else {
$marketplaceFedexShipping = ['mpupshipping' => $rates];
}

array_push($shippingMethods, $object);
}

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

Expand Down
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

1 comment on commit 940103a

@VikassWebkul214254
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to optimise code.

Please sign in to comment.