Merge branch 'master' of https://github.com/bagisto/bagisto into prashant
This commit is contained in:
commit
9df49c07d3
|
|
@ -639,6 +639,8 @@ class Cart {
|
|||
}
|
||||
}
|
||||
|
||||
$this->calulateTax();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -698,6 +700,8 @@ class Cart {
|
|||
if(!$cart = $this->getCart())
|
||||
return false;
|
||||
|
||||
$this->calulateItemsTax();
|
||||
|
||||
$cart->grand_total = 0;
|
||||
$cart->base_grand_total = 0;
|
||||
|
||||
|
|
@ -735,6 +739,20 @@ class Cart {
|
|||
$cart->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates cart items tax
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function calulateItemsTax()
|
||||
{
|
||||
$cart = $this->getCart();
|
||||
|
||||
foreach ($cart->items()->get() as $item) {
|
||||
$product = $item->product;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if cart has any error
|
||||
*
|
||||
|
|
|
|||
|
|
@ -41,8 +41,8 @@ class CreateCartTable extends Migration
|
|||
$table->decimal('tax_total', 12, 4)->default(0)->nullable();
|
||||
$table->decimal('base_tax_total', 12, 4)->default(0)->nullable();
|
||||
|
||||
$table->decimal('sub_total_with_discount', 12, 4)->default(0)->nullable();
|
||||
$table->decimal('base_sub_total_with_discount', 12, 4)->default(0)->nullable();
|
||||
$table->decimal('discount', 12, 4)->default(0)->nullable();
|
||||
$table->decimal('base_discount', 12, 4)->default(0)->nullable();
|
||||
|
||||
$table->string('checkout_method')->nullable();
|
||||
$table->boolean('is_guest')->nullable();
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ class CreateCartItemsTable extends Migration
|
|||
$table->string('sku')->nullable();
|
||||
$table->string('type')->nullable();
|
||||
$table->string('name')->nullable();
|
||||
$table->integer('parent_id')->unsigned()->nullable();
|
||||
$table->string('coupon_code')->nullable();
|
||||
$table->decimal('weight', 12,4)->default(1);
|
||||
$table->decimal('total_weight', 12,4)->default(0);
|
||||
|
|
@ -35,18 +34,14 @@ class CreateCartItemsTable extends Migration
|
|||
$table->decimal('tax_percent', 12, 4)->default(0)->nullable();
|
||||
$table->decimal('tax_amount', 12, 4)->default(0)->nullable();
|
||||
$table->decimal('base_tax_amount', 12, 4)->default(0)->nullable();
|
||||
|
||||
$table->decimal('total_with_discount', 12,4)->default(0);
|
||||
$table->decimal('base_total_with_discount', 12,4)->default(0);
|
||||
|
||||
$table->decimal('discount_percent', 12,4)->default(0);
|
||||
$table->decimal('discount_amount', 12,4)->default(0);
|
||||
$table->decimal('base_discount_amount', 12,4)->default(0);
|
||||
$table->boolean('no_discount')->nullable()->default(0);
|
||||
|
||||
$table->boolean('free_shipping')->nullable()->default(0);
|
||||
$table->json('additional')->nullable();
|
||||
|
||||
$table->integer('parent_id')->unsigned()->nullable();
|
||||
$table->integer('product_id')->unsigned();
|
||||
$table->foreign('product_id')->references('id')->on('products')->onDelete('cascade');
|
||||
$table->integer('cart_id')->unsigned();
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
namespace Webkul\Checkout\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Webkul\Product\Models\Product;
|
||||
|
||||
|
||||
class CartItem extends Model
|
||||
|
|
@ -16,17 +17,9 @@ class CartItem extends Model
|
|||
protected $guarded = ['id', 'created_at', 'updated_at'];
|
||||
|
||||
public function product() {
|
||||
return $this->hasOne('Webkul\Product\Models\Product', 'id', 'product_id');
|
||||
return $this->hasOne(Product::class, 'id', 'product_id');
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Get the parent item
|
||||
// */
|
||||
// public function parent()
|
||||
// {
|
||||
// return $this->hasOne(self::class, 'parent_id', 'id');
|
||||
// }
|
||||
|
||||
/**
|
||||
* Get the child item.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue