Skip to content
This repository was archived by the owner on Sep 28, 2019. It is now read-only.

Commit 9b21107

Browse files
committed
updated free shipping to use new avoredfieldcheckout
1 parent 23b3495 commit 9b21107

File tree

2 files changed

+49
-3
lines changed

2 files changed

+49
-3
lines changed

resources/views/shipping/free-shipping.blade.php

Lines changed: 36 additions & 0 deletions
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 () {

src/Shipping/FreeShipping.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
class FreeShipping extends AbstractShipping implements ShippingContract
1111
{
12-
1312
const CONFIG_KEY = 'shipping_free_shipping_enabled';
1413

1514
/**
@@ -90,7 +89,6 @@ public function amount()
9089
return $this->amount;
9190
}
9291

93-
9492
/**
9593
* Payment Option View Path.
9694
*
@@ -111,7 +109,6 @@ public function with()
111109
return [];
112110
}
113111

114-
115112
/**
116113
* Processing Amount for this Shipping Option.
117114
*
@@ -125,4 +122,17 @@ public function process($cartProducts)
125122

126123
return $this;
127124
}
125+
126+
/**
127+
* Calculate the cost of Shipping based on Checkout Form Data.
128+
*
129+
* @param \Illuminate\Support\Collection $cartProducts
130+
* @return self
131+
*/
132+
public function calculate($checkoutFormData)
133+
{
134+
$view = view($this->view)->with('shippingOption', $this);
135+
136+
return $view->render();
137+
}
128138
}

0 commit comments

Comments
 (0)