Skip to content

Commit e9466ca

Browse files
committed
updated fixed rate shipping with new setup
1 parent 4795c5c commit e9466ca

File tree

2 files changed

+51
-7
lines changed

2 files changed

+51
-7
lines changed
Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,39 @@
1+
2+
@if($shippingOption->enable())
3+
<div class="form-check">
4+
5+
<input type="radio" name="shipping_option"
6+
7+
data-title="{{ $shippingOption->name() }}"
8+
data-cost="{{ number_format($shippingOption->amount(),2) }}"
9+
id="{{ $shippingOption->identifier() }}"
10+
value="{{ $shippingOption->identifier() }}"
11+
12+
@if($errors->has('shipping_option'))
13+
class="is-invalid form-check-input shipping_option_radio"
14+
@else
15+
class="shipping_option_radio form-check-input"
16+
@endif
17+
18+
/>
19+
20+
<label for="{{ $shippingOption->identifier() }}" class="form-check-label">
21+
@if(null === $shippingOption->amount())
22+
{{ $shippingOption->name() }}
23+
@else
24+
{{ $shippingOption->name() . " $" . number_format($shippingOption->amount(),2) }}
25+
@endif
26+
</label>
27+
@if ($errors->has('shipping_option'))
28+
<div class="invalid-feedback" style="display: block">
29+
{{ $errors->first('shipping_option') }}
30+
</div>
31+
@endif
32+
33+
</div>
34+
35+
@endif
36+
137
@push('scripts')
238
<script>
339
$(document).ready(function () {
@@ -6,4 +42,4 @@
642
});
743
844
</script>
9-
@endpush
45+
@endpush

src/Shipping/FixedRate.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@
88

99
class FixedRate extends AbstractShipping implements ShippingContract
1010
{
11-
1211
const CONFIX_FIXED_RATE_COST = 'shipping_fixed_rate_cost';
13-
14-
12+
1513
const CONFIG_KEY = 'shipping_fixed_rate_shipping_enabled';
1614

1715
/**
@@ -72,7 +70,6 @@ public function name()
7270
*/
7371
public function enable()
7472
{
75-
7673
$this->enable = Configuration::getConfiguration(self::CONFIG_KEY);
7774

7875
return $this->enable;
@@ -89,7 +86,6 @@ public function amount()
8986
return $this->amount;
9087
}
9188

92-
9389
/**
9490
* Payment Option View Path.
9591
*
@@ -110,7 +106,6 @@ public function with()
110106
return [];
111107
}
112108

113-
114109
/**
115110
* Processing Amount for this Shipping Option.
116111
*
@@ -124,4 +119,17 @@ public function process($cartProducts)
124119

125120
return $this;
126121
}
122+
123+
/**
124+
* Processing Amount for this Shipping Option.
125+
*
126+
* @param $orderFormData
127+
* @return self
128+
*/
129+
public function calculate($orderFormData)
130+
{
131+
$view = view($this->view)->with('shippingOption', $this);
132+
133+
return $view->render();
134+
}
127135
}

0 commit comments

Comments
 (0)