-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* make changes to the coupons table and coupons settings * apply coupon on delivery fee full integration * added data migration to the coupon migration file and moved those code mentioned from beforeApply to calculateDeliveryDiscount function * Fix code style Signed-off-by: Sam Poyigi <[email protected]> * Fix code style Signed-off-by: Sam Poyigi <[email protected]> --------- Signed-off-by: Sam Poyigi <[email protected]> Co-authored-by: Sam Poyigi <[email protected]>
- Loading branch information
1 parent
8f7199c
commit 1ea6ae8
Showing
5 changed files
with
82 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...e/migrations/2023_10_19_010000_change_is_limited_to_cart_item_to_apply_coupon_on_enum.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace Igniter\Coupons\Database\Migrations; | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\DB; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
class ChangeIsLimitedToCartItemToApplyCouponOnEnum extends Migration | ||
{ | ||
public function up() | ||
{ | ||
Schema::table('igniter_coupons', function (Blueprint $table) { | ||
$table->enum( | ||
'apply_coupon_on', | ||
['whole_cart', 'menu_items', 'delivery_fee'] | ||
)->default('whole_cart')->after('order_restriction'); | ||
}); | ||
$this->updateApplyCouponOnEnum(); | ||
Schema::table('igniter_coupons', function (Blueprint $table) { | ||
$table->dropColumn('is_limited_to_cart_item'); | ||
}); | ||
} | ||
|
||
// migrate is_limited_to_cart_item to the new apply_coupon_on enum that supports multiple options | ||
protected function updateApplyCouponOnEnum() | ||
{ | ||
DB::table('igniter_coupons') | ||
->where('is_limited_to_cart_item', 1)->get()->each( | ||
function ($model) { | ||
DB::table('igniter_coupons') | ||
->where('coupon_id', $model->coupon_id) | ||
->update([ | ||
'apply_coupon_on' => 'menu_items', | ||
]); | ||
} | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters