parent
7b612ecc67
commit
8e3c43bd19
|
|
@ -13,12 +13,12 @@ namespace Database\Factories;
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class UserFactory extends \Illuminate\Database\Eloquent\Factories\Factory
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
{
|
|
||||||
|
|
||||||
|
class UserFactory extends Factory
|
||||||
|
{
|
||||||
public function definition(): array
|
public function definition(): array
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -6,15 +6,13 @@ use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
class Attribute extends JsonResource
|
class Attribute extends JsonResource
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transform the resource into an array.
|
* Transform the resource into an array.
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Http\Request
|
* @param \Illuminate\Http\Request
|
||||||
*
|
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function toArray($request)
|
public function toArray($request): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
|
|
@ -27,5 +25,4 @@ class Attribute extends JsonResource
|
||||||
'updated_at' => $this->updated_at,
|
'updated_at' => $this->updated_at,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -6,15 +6,13 @@ use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
class AttributeOption extends JsonResource
|
class AttributeOption extends JsonResource
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transform the resource into an array.
|
* Transform the resource into an array.
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Http\Request
|
* @param \Illuminate\Http\Request
|
||||||
*
|
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function toArray($request)
|
public function toArray($request): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
|
|
@ -23,5 +21,4 @@ class AttributeOption extends JsonResource
|
||||||
'swatch_value' => $this->swatch_value,
|
'swatch_value' => $this->swatch_value,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -40,7 +40,7 @@ class AttributeOption extends TranslatableModel implements AttributeOptionContra
|
||||||
return url('cache/small/' . $this->swatch_value);
|
return url('cache/small/' . $this->swatch_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
class AttributeServiceProvider extends ServiceProvider
|
class AttributeServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bootstrap services.
|
* Bootstrap services.
|
||||||
*
|
*
|
||||||
|
|
@ -16,5 +15,4 @@ class AttributeServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
$this->loadMigrationsFrom(__DIR__.'/../Database/Migrations');
|
$this->loadMigrationsFrom(__DIR__.'/../Database/Migrations');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -6,7 +6,6 @@ use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
class BookingProductServiceProvider extends ServiceProvider
|
class BookingProductServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bootstrap services.
|
* Bootstrap services.
|
||||||
*
|
*
|
||||||
|
|
@ -38,5 +37,4 @@ class BookingProductServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
$this->mergeConfigFrom(dirname(__DIR__) . '/Config/product_types.php', 'product_types');
|
$this->mergeConfigFrom(dirname(__DIR__) . '/Config/product_types.php', 'product_types');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -30,8 +30,8 @@ class CategoryFactory extends Factory
|
||||||
public function definition(): array
|
public function definition(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'status' => 1,
|
'status' => 1,
|
||||||
'position' => $this->faker->randomDigit(),
|
'position' => $this->faker->randomDigit(),
|
||||||
'parent_id' => 1,
|
'parent_id' => 1,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ use Webkul\Category\Contracts\CategoryTranslation as CategoryTranslationContract
|
||||||
*/
|
*/
|
||||||
class CategoryTranslation extends Model implements CategoryTranslationContract
|
class CategoryTranslation extends Model implements CategoryTranslationContract
|
||||||
{
|
{
|
||||||
|
|
||||||
public $timestamps = false;
|
public $timestamps = false;
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
|
|
@ -26,5 +25,4 @@ class CategoryTranslation extends Model implements CategoryTranslationContract
|
||||||
'meta_keywords',
|
'meta_keywords',
|
||||||
'locale_id',
|
'locale_id',
|
||||||
];
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -22,9 +22,9 @@ class CartAddressFactory extends Factory
|
||||||
public function definition(): array
|
public function definition(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'first_name' => $this->faker->firstName(),
|
'first_name' => $this->faker->firstName(),
|
||||||
'last_name' => $this->faker->lastName,
|
'last_name' => $this->faker->lastName,
|
||||||
'email' => $this->faker->email,
|
'email' => $this->faker->email,
|
||||||
'address_type' => CartAddress::ADDRESS_TYPE_BILLING,
|
'address_type' => CartAddress::ADDRESS_TYPE_BILLING,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,22 +35,22 @@ class CartFactory extends Factory
|
||||||
->create();
|
->create();
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'is_guest' => 0,
|
'is_guest' => 0,
|
||||||
'is_active' => 1,
|
'is_active' => 1,
|
||||||
'customer_id' => $customer->id,
|
'customer_id' => $customer->id,
|
||||||
'customer_email' => $customer->email,
|
'customer_email' => $customer->email,
|
||||||
'customer_first_name' => $customer->first_name,
|
'customer_first_name' => $customer->first_name,
|
||||||
'customer_last_name' => $customer->last_name,
|
'customer_last_name' => $customer->last_name,
|
||||||
'is_gift' => 0,
|
'is_gift' => 0,
|
||||||
'base_currency_code' => 'EUR',
|
'base_currency_code' => 'EUR',
|
||||||
'channel_currency_code' => 'EUR',
|
'channel_currency_code' => 'EUR',
|
||||||
'grand_total' => 0.0000,
|
'grand_total' => 0.0000,
|
||||||
'base_grand_total' => 0.0000,
|
'base_grand_total' => 0.0000,
|
||||||
'sub_total' => 0.0000,
|
'sub_total' => 0.0000,
|
||||||
'base_sub_total' => 0.0000,
|
'base_sub_total' => 0.0000,
|
||||||
'channel_id' => 1,
|
'channel_id' => 1,
|
||||||
'created_at' => $now,
|
'created_at' => $now,
|
||||||
'updated_at' => $now,
|
'updated_at' => $now,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,16 +38,16 @@ class CartItemFactory extends Factory
|
||||||
$fallbackPrice = $this->faker->randomFloat(4, 0, 1000);
|
$fallbackPrice = $this->faker->randomFloat(4, 0, 1000);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'quantity' => 1,
|
'quantity' => 1,
|
||||||
'sku' => $product->sku,
|
'sku' => $product->sku,
|
||||||
'type' => $product->type,
|
'type' => $product->type,
|
||||||
'name' => $product->name,
|
'name' => $product->name,
|
||||||
'price' => $product->price ?? $fallbackPrice,
|
'price' => $product->price ?? $fallbackPrice,
|
||||||
'base_price' => $product->price ?? $fallbackPrice,
|
'base_price' => $product->price ?? $fallbackPrice,
|
||||||
'total' => $product->price ?? $fallbackPrice,
|
'total' => $product->price ?? $fallbackPrice,
|
||||||
'base_total' => $product->price ?? $fallbackPrice,
|
'base_total' => $product->price ?? $fallbackPrice,
|
||||||
'product_id' => $product->id,
|
'product_id' => $product->id,
|
||||||
'cart_id' => Cart::factory(),
|
'cart_id' => Cart::factory(),
|
||||||
'created_at' => $now,
|
'created_at' => $now,
|
||||||
'updated_at' => $now,
|
'updated_at' => $now,
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,11 @@ use Webkul\Checkout\Facades\Cart;
|
||||||
|
|
||||||
class CheckoutServiceProvider extends ServiceProvider
|
class CheckoutServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
|
|
||||||
public function boot(): void
|
public function boot(): void
|
||||||
{
|
{
|
||||||
include __DIR__.'/../Http/helpers.php';
|
include __DIR__ . '/../Http/helpers.php';
|
||||||
|
|
||||||
$this->loadMigrationsFrom(__DIR__.'/../Database/Migrations');
|
$this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations');
|
||||||
|
|
||||||
$this->app->register(ModuleServiceProvider::class);
|
$this->app->register(ModuleServiceProvider::class);
|
||||||
|
|
||||||
|
|
@ -49,5 +48,4 @@ class CheckoutServiceProvider extends ServiceProvider
|
||||||
|
|
||||||
$this->app->bind('cart', 'Webkul\Checkout\Cart');
|
$this->app->bind('cart', 'Webkul\Checkout\Cart');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -145,7 +145,7 @@ class Core
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns currenct channel models.
|
* Returns current channel models.
|
||||||
*
|
*
|
||||||
* @return \Webkul\Core\Contracts\Channel
|
* @return \Webkul\Core\Contracts\Channel
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -24,12 +24,12 @@ class CartRuleCouponFactory extends Factory
|
||||||
public function definition(): array
|
public function definition(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'code' => Str::uuid(),
|
'code' => Str::uuid(),
|
||||||
'usage_limit' => 100,
|
'usage_limit' => 100,
|
||||||
'usage_per_customer' => 100,
|
'usage_per_customer' => 100,
|
||||||
'type' => 0,
|
'type' => 0,
|
||||||
'is_primary' => 1,
|
'is_primary' => 1,
|
||||||
'cart_rule_id' => CartRule::factory(),
|
'cart_rule_id' => CartRule::factory(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,25 +23,25 @@ class CartRuleFactory extends Factory
|
||||||
public function definition(): array
|
public function definition(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'name' => Str::uuid(),
|
'name' => Str::uuid(),
|
||||||
'description' => $this->faker->sentence(),
|
'description' => $this->faker->sentence(),
|
||||||
'starts_from' => null,
|
'starts_from' => null,
|
||||||
'ends_till' => null,
|
'ends_till' => null,
|
||||||
'coupon_type' => '1',
|
'coupon_type' => '1',
|
||||||
'use_auto_generation' => '0',
|
'use_auto_generation' => '0',
|
||||||
'usage_per_customer' => '100',
|
'usage_per_customer' => '100',
|
||||||
'uses_per_coupon' => '100',
|
'uses_per_coupon' => '100',
|
||||||
'times_used' => '0',
|
'times_used' => '0',
|
||||||
'condition_type' => '2',
|
'condition_type' => '2',
|
||||||
'end_other_rules' => '0',
|
'end_other_rules' => '0',
|
||||||
'uses_attribute_conditions' => '0',
|
'uses_attribute_conditions' => '0',
|
||||||
'discount_quantity' => '0',
|
'discount_quantity' => '0',
|
||||||
'discount_step' => '0',
|
'discount_step' => '0',
|
||||||
'apply_to_shipping' => '0',
|
'apply_to_shipping' => '0',
|
||||||
'free_shipping' => '0',
|
'free_shipping' => '0',
|
||||||
'sort_order' => '0',
|
'sort_order' => '0',
|
||||||
'status' => '1',
|
'status' => '1',
|
||||||
'conditions' => null,
|
'conditions' => null,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -26,23 +26,23 @@ class ChannelFactory extends Factory
|
||||||
*/
|
*/
|
||||||
public function definition(): array
|
public function definition(): array
|
||||||
{
|
{
|
||||||
$seoTitle = $this->faker->word;
|
$seoTitle = $this->faker->word;
|
||||||
$seoDescription = $this->faker->words(10, true);
|
$seoDescription = $this->faker->words(10, true);
|
||||||
$seoKeywords = $this->faker->words(3, true);
|
$seoKeywords = $this->faker->words(3, true);
|
||||||
|
|
||||||
$seoData = [
|
$seoData = [
|
||||||
'meta_title' => $seoTitle,
|
'meta_title' => $seoTitle,
|
||||||
'meta_description' => $seoDescription,
|
'meta_description' => $seoDescription,
|
||||||
'meta_keywords' => $seoKeywords,
|
'meta_keywords' => $seoKeywords,
|
||||||
];
|
];
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'code' => $this->faker->unique()->word,
|
'code' => $this->faker->unique()->word,
|
||||||
'name' => $this->faker->word,
|
'name' => $this->faker->word,
|
||||||
'default_locale_id' => Locale::factory(),
|
'default_locale_id' => Locale::factory(),
|
||||||
'base_currency_id' => Currency::factory(),
|
'base_currency_id' => Currency::factory(),
|
||||||
'root_category_id' => Category::factory(),
|
'root_category_id' => Category::factory(),
|
||||||
'home_seo' => json_encode($seoData, JSON_THROW_ON_ERROR),
|
'home_seo' => json_encode($seoData, JSON_THROW_ON_ERROR),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -21,7 +21,7 @@ class ChannelInventorySourceFactory extends Factory
|
||||||
public function definition(): array
|
public function definition(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'channel_id' => core()->getCurrentChannel()->id,
|
'channel_id' => core()->getCurrentChannel()->id,
|
||||||
'inventory_source_id' => 1,
|
'inventory_source_id' => 1,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,8 @@ class LocaleFactory extends Factory
|
||||||
->exists());
|
->exists());
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'code' => $languageCode,
|
'code' => $languageCode,
|
||||||
'name' => $this->faker->country,
|
'name' => $this->faker->country,
|
||||||
'direction' => 'ltr',
|
'direction' => 'ltr',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,9 +22,9 @@ class SubscriberListFactory extends Factory
|
||||||
public function definition(): array
|
public function definition(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'email' => $this->faker->safeEmail,
|
'email' => $this->faker->safeEmail,
|
||||||
'is_subscribed' => $this->faker->boolean,
|
'is_subscribed' => $this->faker->boolean,
|
||||||
'channel_id' => 1,
|
'channel_id' => 1,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,6 @@ use Webkul\Product\Models\ProductDownloadableLinkTranslation;
|
||||||
*/
|
*/
|
||||||
class Laravel5Helper extends Laravel
|
class Laravel5Helper extends Laravel
|
||||||
{
|
{
|
||||||
|
|
||||||
public const SIMPLE_PRODUCT = 1;
|
public const SIMPLE_PRODUCT = 1;
|
||||||
|
|
||||||
public const VIRTUAL_PRODUCT = 2;
|
public const VIRTUAL_PRODUCT = 2;
|
||||||
|
|
@ -89,10 +88,10 @@ class Laravel5Helper extends Laravel
|
||||||
|
|
||||||
if (isset($options['payment_method'])
|
if (isset($options['payment_method'])
|
||||||
&& $options['payment_method'] === 'free_of_charge') {
|
&& $options['payment_method'] === 'free_of_charge') {
|
||||||
$grand_total = '0.0000';
|
$grand_total = '0.0000';
|
||||||
$base_grand_total = '0.0000';
|
$base_grand_total = '0.0000';
|
||||||
} else {
|
} else {
|
||||||
$grand_total = (string) $faker->numberBetween(1, 666);
|
$grand_total = (string)$faker->numberBetween(1, 666);
|
||||||
$base_grand_total = $grand_total;
|
$base_grand_total = $grand_total;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -133,7 +132,7 @@ class Laravel5Helper extends Laravel
|
||||||
|
|
||||||
// actually set the cart to the user's session
|
// actually set the cart to the user's session
|
||||||
// when in an functional test:
|
// when in an functional test:
|
||||||
$stub = new StdClass();
|
$stub = new StdClass();
|
||||||
$stub->id = $cart->id;
|
$stub->id = $cart->id;
|
||||||
$I->setSession(['cart' => $stub]);
|
$I->setSession(['cart' => $stub]);
|
||||||
|
|
||||||
|
|
@ -295,7 +294,7 @@ class Laravel5Helper extends Laravel
|
||||||
|
|
||||||
private function createDownloadableLink(int $productId): void
|
private function createDownloadableLink(int $productId): void
|
||||||
{
|
{
|
||||||
$I = $this;
|
$I = $this;
|
||||||
$link = $I->have(ProductDownloadableLink::class, [
|
$link = $I->have(ProductDownloadableLink::class, [
|
||||||
'product_id' => $productId,
|
'product_id' => $productId,
|
||||||
]);
|
]);
|
||||||
|
|
@ -307,7 +306,7 @@ class Laravel5Helper extends Laravel
|
||||||
|
|
||||||
private function createBookingEventProduct(int $productId): void
|
private function createBookingEventProduct(int $productId): void
|
||||||
{
|
{
|
||||||
$I = $this;
|
$I = $this;
|
||||||
$bookingProduct = $I->have(BookingProduct::class, [
|
$bookingProduct = $I->have(BookingProduct::class, [
|
||||||
'product_id' => $productId,
|
'product_id' => $productId,
|
||||||
]);
|
]);
|
||||||
|
|
@ -392,7 +391,7 @@ class Laravel5Helper extends Laravel
|
||||||
*/
|
*/
|
||||||
private function appendAttributeDependencies(string $attributeCode, array $data): array
|
private function appendAttributeDependencies(string $attributeCode, array $data): array
|
||||||
{
|
{
|
||||||
$locale = core()->getCurrentLocale()->code;
|
$locale = core()->getCurrentLocale()->code;
|
||||||
$channel = core()->getCurrentChannelCode();
|
$channel = core()->getCurrentChannelCode();
|
||||||
|
|
||||||
$attributeSetDependencies = [
|
$attributeSetDependencies = [
|
||||||
|
|
@ -451,5 +450,4 @@ class Laravel5Helper extends Laravel
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
namespace Webkul\Core\Models;
|
namespace Webkul\Core\Models;
|
||||||
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
|
@ -12,7 +10,6 @@ use Webkul\Core\Contracts\Address as AddressContract;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Address
|
* Class Address
|
||||||
*
|
|
||||||
* @package Webkul\Core\Models
|
* @package Webkul\Core\Models
|
||||||
*
|
*
|
||||||
* @property string $address_type
|
* @property string $address_type
|
||||||
|
|
@ -41,7 +38,6 @@ use Webkul\Core\Contracts\Address as AddressContract;
|
||||||
*/
|
*/
|
||||||
abstract class Address extends Model implements AddressContract
|
abstract class Address extends Model implements AddressContract
|
||||||
{
|
{
|
||||||
|
|
||||||
protected $table = 'addresses';
|
protected $table = 'addresses';
|
||||||
|
|
||||||
protected $guarded = [
|
protected $guarded = [
|
||||||
|
|
@ -82,7 +78,7 @@ abstract class Address extends Model implements AddressContract
|
||||||
*/
|
*/
|
||||||
public function getNameAttribute(): string
|
public function getNameAttribute(): string
|
||||||
{
|
{
|
||||||
return $this->first_name.' '.$this->last_name;
|
return $this->first_name . ' ' . $this->last_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -92,5 +88,4 @@ abstract class Address extends Model implements AddressContract
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Customer::class);
|
return $this->belongsTo(Customer::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ use Konekt\Concord\BaseModuleServiceProvider;
|
||||||
|
|
||||||
class CoreModuleServiceProvider extends BaseModuleServiceProvider
|
class CoreModuleServiceProvider extends BaseModuleServiceProvider
|
||||||
{
|
{
|
||||||
public function boot()
|
public function boot(): void
|
||||||
{
|
{
|
||||||
if ($this->areMigrationsEnabled()) {
|
if ($this->areMigrationsEnabled()) {
|
||||||
$this->registerMigrations();
|
$this->registerMigrations();
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@ use Webkul\Theme\ViewRenderEventManager;
|
||||||
|
|
||||||
class CoreServiceProvider extends ServiceProvider
|
class CoreServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bootstrap services.
|
* Bootstrap services.
|
||||||
*
|
*
|
||||||
|
|
@ -25,11 +24,11 @@ class CoreServiceProvider extends ServiceProvider
|
||||||
*/
|
*/
|
||||||
public function boot(): void
|
public function boot(): void
|
||||||
{
|
{
|
||||||
include __DIR__.'/../Http/helpers.php';
|
include __DIR__ . '/../Http/helpers.php';
|
||||||
|
|
||||||
$this->loadMigrationsFrom(__DIR__.'/../Database/Migrations');
|
$this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations');
|
||||||
|
|
||||||
$this->loadTranslationsFrom(__DIR__.'/../Resources/lang', 'core');
|
$this->loadTranslationsFrom(__DIR__ . '/../Resources/lang', 'core');
|
||||||
|
|
||||||
Validator::extend('slug', 'Webkul\Core\Contracts\Validations\Slug@passes');
|
Validator::extend('slug', 'Webkul\Core\Contracts\Validations\Slug@passes');
|
||||||
|
|
||||||
|
|
@ -38,15 +37,15 @@ class CoreServiceProvider extends ServiceProvider
|
||||||
Validator::extend('decimal', 'Webkul\Core\Contracts\Validations\Decimal@passes');
|
Validator::extend('decimal', 'Webkul\Core\Contracts\Validations\Decimal@passes');
|
||||||
|
|
||||||
$this->publishes([
|
$this->publishes([
|
||||||
dirname(__DIR__).'/Config/concord.php' => config_path('concord.php'),
|
dirname(__DIR__) . '/Config/concord.php' => config_path('concord.php'),
|
||||||
dirname(__DIR__).'/Config/scout.php' => config_path('scout.php'),
|
dirname(__DIR__) . '/Config/scout.php' => config_path('scout.php'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->app->bind(ExceptionHandler::class, Handler::class);
|
$this->app->bind(ExceptionHandler::class, Handler::class);
|
||||||
|
|
||||||
SliderProxy::observe(SliderObserver::class);
|
SliderProxy::observe(SliderObserver::class);
|
||||||
|
|
||||||
$this->loadViewsFrom(__DIR__.'/../Resources/views', 'core');
|
$this->loadViewsFrom(__DIR__ . '/../Resources/views', 'core');
|
||||||
|
|
||||||
Event::listen('bagisto.shop.layout.body.after', static function (ViewRenderEventManager $viewRenderEventManager) {
|
Event::listen('bagisto.shop.layout.body.after', static function (ViewRenderEventManager $viewRenderEventManager) {
|
||||||
$viewRenderEventManager->addTemplate('core::blade.tracer.style');
|
$viewRenderEventManager->addTemplate('core::blade.tracer.style');
|
||||||
|
|
@ -127,5 +126,4 @@ class CoreServiceProvider extends ServiceProvider
|
||||||
return new BladeCompiler($app['files'], $app['config']['view.compiled']);
|
return new BladeCompiler($app['files'], $app['config']['view.compiled']);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,22 +27,22 @@ class CustomerAddressFactory extends Factory
|
||||||
$fakerIt = \Faker\Factory::create('it_IT');
|
$fakerIt = \Faker\Factory::create('it_IT');
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'customer_id' => Customer::factory(),
|
'customer_id' => Customer::factory(),
|
||||||
'company_name' => $this->faker->company,
|
'company_name' => $this->faker->company,
|
||||||
'vat_id' => $fakerIt->vatId(),
|
'vat_id' => $fakerIt->vatId(),
|
||||||
'first_name' => $this->faker->firstName,
|
'first_name' => $this->faker->firstName,
|
||||||
'last_name' => $this->faker->lastName,
|
'last_name' => $this->faker->lastName,
|
||||||
'address1' => $this->faker->streetAddress,
|
'address1' => $this->faker->streetAddress,
|
||||||
'country' => $this->faker->countryCode,
|
'country' => $this->faker->countryCode,
|
||||||
'state' => $this->faker->state,
|
'state' => $this->faker->state,
|
||||||
'city' => $this->faker->city,
|
'city' => $this->faker->city,
|
||||||
'postcode' => $this->faker->postcode,
|
'postcode' => $this->faker->postcode,
|
||||||
'phone' => $this->faker->e164PhoneNumber,
|
'phone' => $this->faker->e164PhoneNumber,
|
||||||
'default_address' => Arr::random([
|
'default_address' => Arr::random([
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
]),
|
]),
|
||||||
'address_type' => CustomerAddress::ADDRESS_TYPE,
|
'address_type' => CustomerAddress::ADDRESS_TYPE,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,25 +32,25 @@ class CustomerFactory extends Factory
|
||||||
*/
|
*/
|
||||||
public function definition(): array
|
public function definition(): array
|
||||||
{
|
{
|
||||||
$now = date("Y-m-d H:i:s");
|
$now = date("Y-m-d H:i:s");
|
||||||
$password = $this->faker->password;
|
$password = $this->faker->password;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'first_name' => $this->faker->firstName(),
|
'first_name' => $this->faker->firstName(),
|
||||||
'last_name' => $this->faker->lastName,
|
'last_name' => $this->faker->lastName,
|
||||||
'gender' => Arr::random([
|
'gender' => Arr::random([
|
||||||
'male',
|
'male',
|
||||||
'female',
|
'female',
|
||||||
'other',
|
'other',
|
||||||
]),
|
]),
|
||||||
'email' => $this->faker->email,
|
'email' => $this->faker->email,
|
||||||
'status' => 1,
|
'status' => 1,
|
||||||
'password' => Hash::make($password),
|
'password' => Hash::make($password),
|
||||||
'customer_group_id' => 2,
|
'customer_group_id' => 2,
|
||||||
'is_verified' => 1,
|
'is_verified' => 1,
|
||||||
'created_at' => $now,
|
'created_at' => $now,
|
||||||
'updated_at' => $now,
|
'updated_at' => $now,
|
||||||
'notes' => json_encode(['plain_password' => $password], JSON_THROW_ON_ERROR),
|
'notes' => json_encode(['plain_password' => $password], JSON_THROW_ON_ERROR),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,9 +25,9 @@ class CustomerGroupFactory extends Factory
|
||||||
$name = ucfirst($this->faker->word);
|
$name = ucfirst($this->faker->word);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'is_user_defined' => $this->faker->boolean,
|
'is_user_defined' => $this->faker->boolean,
|
||||||
'code' => lcfirst($name),
|
'code' => lcfirst($name),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
namespace Webkul\Customer\Models;
|
namespace Webkul\Customer\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Webkul\Customer\Database\Factories\CustomerGroupFactory;
|
use Webkul\Customer\Database\Factories\CustomerGroupFactory;
|
||||||
use Webkul\Customer\Contracts\CustomerGroup as CustomerGroupContract;
|
use Webkul\Customer\Contracts\CustomerGroup as CustomerGroupContract;
|
||||||
|
|
@ -22,7 +23,7 @@ class CustomerGroup extends Model implements CustomerGroupContract
|
||||||
/**
|
/**
|
||||||
* Get the customers for this group.
|
* Get the customers for this group.
|
||||||
*/
|
*/
|
||||||
public function customers(): \Illuminate\Database\Eloquent\Relations\HasMany
|
public function customers(): HasMany
|
||||||
{
|
{
|
||||||
return $this->hasMany(CustomerProxy::modelClass());
|
return $this->hasMany(CustomerProxy::modelClass());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,21 +10,21 @@ use Webkul\Customer\Http\Middleware\RedirectIfNotCustomer;
|
||||||
|
|
||||||
class CustomerServiceProvider extends ServiceProvider
|
class CustomerServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bootstrap application services.
|
* Bootstrap application services.
|
||||||
*
|
*
|
||||||
|
* @param \Illuminate\Routing\Router $router
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function boot(Router $router)
|
public function boot(Router $router): void
|
||||||
{
|
{
|
||||||
$router->aliasMiddleware('customer', RedirectIfNotCustomer::class);
|
$router->aliasMiddleware('customer', RedirectIfNotCustomer::class);
|
||||||
|
|
||||||
$this->loadMigrationsFrom(__DIR__.'/../Database/Migrations');
|
$this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations');
|
||||||
|
|
||||||
$this->loadTranslationsFrom(__DIR__.'/../Resources/lang', 'customer');
|
$this->loadTranslationsFrom(__DIR__ . '/../Resources/lang', 'customer');
|
||||||
|
|
||||||
$this->loadViewsFrom(__DIR__.'/../Resources/views', 'customer');
|
$this->loadViewsFrom(__DIR__ . '/../Resources/views', 'customer');
|
||||||
|
|
||||||
$this->app['validator']->extend('captcha', function ($attribute, $value, $parameters) {
|
$this->app['validator']->extend('captcha', function ($attribute, $value, $parameters) {
|
||||||
return $this->app['captcha']->validateResponse($value);
|
return $this->app['captcha']->validateResponse($value);
|
||||||
|
|
@ -52,7 +52,6 @@ class CustomerServiceProvider extends ServiceProvider
|
||||||
*/
|
*/
|
||||||
protected function registerConfig(): void
|
protected function registerConfig(): void
|
||||||
{
|
{
|
||||||
$this->mergeConfigFrom(dirname(__DIR__).'/Config/system.php', 'core');
|
$this->mergeConfigFrom(dirname(__DIR__) . '/Config/system.php', 'core');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,24 +21,24 @@ class InventorySourceFactory extends Factory
|
||||||
*/
|
*/
|
||||||
public function definition(): array
|
public function definition(): array
|
||||||
{
|
{
|
||||||
$now = date("Y-m-d H:i:s");
|
$now = date("Y-m-d H:i:s");
|
||||||
$code = $this->faker->unique()->word;
|
$code = $this->faker->unique()->word;
|
||||||
return [
|
return [
|
||||||
'code' => $this->faker->unique()->word,
|
'code' => $this->faker->unique()->word,
|
||||||
'name' => $code,
|
'name' => $code,
|
||||||
'description' => $this->faker->sentence,
|
'description' => $this->faker->sentence,
|
||||||
'contact_name' => $this->faker->name,
|
'contact_name' => $this->faker->name,
|
||||||
'contact_email' => $this->faker->safeEmail,
|
'contact_email' => $this->faker->safeEmail,
|
||||||
'contact_number' => $this->faker->phoneNumber,
|
'contact_number' => $this->faker->phoneNumber,
|
||||||
'country' => $this->faker->countryCode,
|
'country' => $this->faker->countryCode,
|
||||||
'state' => $this->faker->state,
|
'state' => $this->faker->state,
|
||||||
'city' => $this->faker->city,
|
'city' => $this->faker->city,
|
||||||
'street' => $this->faker->streetAddress,
|
'street' => $this->faker->streetAddress,
|
||||||
'postcode' => $this->faker->postcode,
|
'postcode' => $this->faker->postcode,
|
||||||
'priority' => 0,
|
'priority' => 0,
|
||||||
'status' => 1,
|
'status' => 1,
|
||||||
'created_at' => $now,
|
'created_at' => $now,
|
||||||
'updated_at' => $now,
|
'updated_at' => $now,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
class InventoryServiceProvider extends ServiceProvider
|
class InventoryServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bootstrap services.
|
* Bootstrap services.
|
||||||
*
|
*
|
||||||
|
|
@ -14,7 +13,7 @@ class InventoryServiceProvider extends ServiceProvider
|
||||||
*/
|
*/
|
||||||
public function boot(): void
|
public function boot(): void
|
||||||
{
|
{
|
||||||
$this->loadMigrationsFrom(__DIR__.'/../Database/Migrations');
|
$this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -25,5 +24,4 @@ class InventoryServiceProvider extends ServiceProvider
|
||||||
public function register(): void
|
public function register(): void
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -24,8 +24,8 @@ class ProductAttributeValueFactory extends Factory
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
//'product_id' => Product::factory(),
|
//'product_id' => Product::factory(),
|
||||||
'locale' => 'en',
|
'locale' => 'en',
|
||||||
'channel' => 'default',
|
'channel' => 'default',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -22,17 +22,17 @@ class ProductDownloadableLinkFactory extends Factory
|
||||||
*/
|
*/
|
||||||
public function definition(): array
|
public function definition(): array
|
||||||
{
|
{
|
||||||
$now = date("Y-m-d H:i:s");
|
$now = date("Y-m-d H:i:s");
|
||||||
$filename = 'ProductImageExampleForUpload.jpg';
|
$filename = 'ProductImageExampleForUpload.jpg';
|
||||||
$filepath = '/tests/_data/';
|
$filepath = '/tests/_data/';
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'url' => '',
|
'url' => '',
|
||||||
'file' => $filepath . $filename,
|
'file' => $filepath . $filename,
|
||||||
'file_name' => $filename,
|
'file_name' => $filename,
|
||||||
'type' => 'file',
|
'type' => 'file',
|
||||||
'price' => 0.0000,
|
'price' => 0.0000,
|
||||||
'downloads' => $this->faker->randomNumber(1),
|
'downloads' => $this->faker->randomNumber(1),
|
||||||
'product_id' => Product::factory(),
|
'product_id' => Product::factory(),
|
||||||
'created_at' => $now,
|
'created_at' => $now,
|
||||||
'updated_at' => $now,
|
'updated_at' => $now,
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,8 @@ class ProductDownloadableLinkTranslationFactory extends Factory
|
||||||
public function definition(): array
|
public function definition(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'locale' => 'en',
|
'locale' => 'en',
|
||||||
'title' => $this->faker->word,
|
'title' => $this->faker->word,
|
||||||
'product_downloadable_link_id' => ProductDownloadableLink::factory(),
|
'product_downloadable_link_id' => ProductDownloadableLink::factory(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ class ProductFactory extends Factory
|
||||||
public function definition(): array
|
public function definition(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'sku' => $this->faker->uuid,
|
'sku' => $this->faker->uuid,
|
||||||
'attribute_family_id' => 1,
|
'attribute_family_id' => 1,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,8 @@ class ProductInventoryFactory extends Factory
|
||||||
public function definition(): array
|
public function definition(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'qty' => $this->faker->numberBetween(100, 200),
|
'qty' => $this->faker->numberBetween(100, 200),
|
||||||
'product_id' => Product::factory(),
|
'product_id' => Product::factory(),
|
||||||
'inventory_source_id' => InventorySource::factory(),
|
'inventory_source_id' => InventorySource::factory(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,10 +23,10 @@ class ProductReviewFactory extends Factory
|
||||||
public function definition(): array
|
public function definition(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'title' => $this->faker->words(5, true),
|
'title' => $this->faker->words(5, true),
|
||||||
'rating' => $this->faker->numberBetween(0, 10),
|
'rating' => $this->faker->numberBetween(0, 10),
|
||||||
'status' => 1,
|
'status' => 1,
|
||||||
'comment' => $this->faker->sentence(20),
|
'comment' => $this->faker->sentence(20),
|
||||||
'product_id' => Product::factory(),
|
'product_id' => Product::factory(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Webkul\Category\Database\Seeders;
|
namespace Webkul\Product\Database\Seeders;
|
||||||
|
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Database\Seeder;
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
class ProductTableSeeder extends Seeder
|
class ProductTableSeeder extends Seeder
|
||||||
{
|
{
|
||||||
public function run()
|
public function run(): void
|
||||||
{
|
{
|
||||||
//dd('running');
|
//dd('running');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,21 +17,21 @@ class GenerateProduct
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Product Repository instance
|
* Product Repository instance
|
||||||
*
|
*
|
||||||
* @var \Webkul\Product\Repositories\ProductRepository
|
* @var \Webkul\Product\Repositories\ProductRepository
|
||||||
*/
|
*/
|
||||||
protected $productRepository;
|
protected $productRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AttributeFamily Repository instance
|
* AttributeFamily Repository instance
|
||||||
*
|
*
|
||||||
* @var \Webkul\Product\Repositories\AttributeFamilyRepository
|
* @var \Webkul\Product\Repositories\AttributeFamilyRepository
|
||||||
*/
|
*/
|
||||||
protected $attributeFamilyRepository;
|
protected $attributeFamilyRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Product Attribute Types
|
* Product Attribute Types
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $types;
|
protected $types;
|
||||||
|
|
@ -70,7 +70,7 @@ class GenerateProduct
|
||||||
/**
|
/**
|
||||||
* This brand option needs to be available so that the generated product
|
* This brand option needs to be available so that the generated product
|
||||||
* can be linked to the order_brands table after checkout.
|
* can be linked to the order_brands table after checkout.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function generateDemoBrand()
|
public function generateDemoBrand()
|
||||||
|
|
|
||||||
|
|
@ -421,7 +421,7 @@ class Product extends Model implements ProductContract
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$locale = core()->checkRequestedLocaleCodeInRequestedChannel();
|
$locale = core()->checkRequestedLocaleCodeInRequestedChannel();
|
||||||
$channel = core()->getRequestedChannelCode();
|
$channel = core()->getRequestedChannelCode();
|
||||||
|
|
||||||
if (array_key_exists($this->id, self::$loadedAttributeValues)
|
if (array_key_exists($this->id, self::$loadedAttributeValues)
|
||||||
|
|
|
||||||
|
|
@ -26,17 +26,17 @@ class ProductAttributeValue extends Model implements ProductAttributeValueContra
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public static $attributeTypeFields = [
|
public static $attributeTypeFields = [
|
||||||
'text' => 'text_value',
|
'text' => 'text_value',
|
||||||
'textarea' => 'text_value',
|
'textarea' => 'text_value',
|
||||||
'price' => 'float_value',
|
'price' => 'float_value',
|
||||||
'boolean' => 'boolean_value',
|
'boolean' => 'boolean_value',
|
||||||
'select' => 'integer_value',
|
'select' => 'integer_value',
|
||||||
'multiselect' => 'text_value',
|
'multiselect' => 'text_value',
|
||||||
'datetime' => 'datetime_value',
|
'datetime' => 'datetime_value',
|
||||||
'date' => 'date_value',
|
'date' => 'date_value',
|
||||||
'file' => 'text_value',
|
'file' => 'text_value',
|
||||||
'image' => 'text_value',
|
'image' => 'text_value',
|
||||||
'checkbox' => 'text_value',
|
'checkbox' => 'text_value',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ use Webkul\Product\ProductVideo;
|
||||||
|
|
||||||
class ProductServiceProvider extends ServiceProvider
|
class ProductServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bootstrap services.
|
* Bootstrap services.
|
||||||
*
|
*
|
||||||
|
|
@ -23,14 +22,14 @@ class ProductServiceProvider extends ServiceProvider
|
||||||
*/
|
*/
|
||||||
public function boot(): void
|
public function boot(): void
|
||||||
{
|
{
|
||||||
include __DIR__.'/../Http/helpers.php';
|
include __DIR__ . '/../Http/helpers.php';
|
||||||
|
|
||||||
$this->loadMigrationsFrom(__DIR__.'/../Database/Migrations');
|
$this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations');
|
||||||
|
|
||||||
$this->app->register(EventServiceProvider::class);
|
$this->app->register(EventServiceProvider::class);
|
||||||
|
|
||||||
$this->publishes([
|
$this->publishes([
|
||||||
dirname(__DIR__).'/Config/imagecache.php' => config_path('imagecache.php'),
|
dirname(__DIR__) . '/Config/imagecache.php' => config_path('imagecache.php'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
ProductProxy::observe(ProductObserver::class);
|
ProductProxy::observe(ProductObserver::class);
|
||||||
|
|
@ -57,7 +56,7 @@ class ProductServiceProvider extends ServiceProvider
|
||||||
*/
|
*/
|
||||||
public function registerConfig(): void
|
public function registerConfig(): void
|
||||||
{
|
{
|
||||||
$this->mergeConfigFrom(dirname(__DIR__).'/Config/product_types.php', 'product_types');
|
$this->mergeConfigFrom(dirname(__DIR__) . '/Config/product_types.php', 'product_types');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -97,5 +96,4 @@ class ProductServiceProvider extends ServiceProvider
|
||||||
return app()->make(ProductVideo::class);
|
return app()->make(ProductVideo::class);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -32,9 +32,9 @@ class InvoiceFactory extends Factory
|
||||||
*/
|
*/
|
||||||
public function definition(): array
|
public function definition(): array
|
||||||
{
|
{
|
||||||
$subTotal = $this->faker->randomFloat(2);
|
$subTotal = $this->faker->randomFloat(2);
|
||||||
$shippingAmount = $this->faker->randomFloat(2);
|
$shippingAmount = $this->faker->randomFloat(2);
|
||||||
$taxAmount = $this->faker->randomFloat(2);
|
$taxAmount = $this->faker->randomFloat(2);
|
||||||
|
|
||||||
if (!isset($attributes['order_id'])) {
|
if (!isset($attributes['order_id'])) {
|
||||||
$attributes['order_id'] = Order::factory();
|
$attributes['order_id'] = Order::factory();
|
||||||
|
|
@ -45,23 +45,23 @@ class InvoiceFactory extends Factory
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'email_sent' => 0,
|
'email_sent' => 0,
|
||||||
'total_qty' => $this->faker->randomNumber(),
|
'total_qty' => $this->faker->randomNumber(),
|
||||||
'base_currency_code' => 'EUR',
|
'base_currency_code' => 'EUR',
|
||||||
'channel_currency_code' => 'EUR',
|
'channel_currency_code' => 'EUR',
|
||||||
'order_currency_code' => 'EUR',
|
'order_currency_code' => 'EUR',
|
||||||
'sub_total' => $subTotal,
|
'sub_total' => $subTotal,
|
||||||
'base_sub_total' => $subTotal,
|
'base_sub_total' => $subTotal,
|
||||||
'grand_total' => $subTotal,
|
'grand_total' => $subTotal,
|
||||||
'base_grand_total' => $subTotal,
|
'base_grand_total' => $subTotal,
|
||||||
'shipping_amount' => $shippingAmount,
|
'shipping_amount' => $shippingAmount,
|
||||||
'base_shipping_amount' => $shippingAmount,
|
'base_shipping_amount' => $shippingAmount,
|
||||||
'tax_amount' => $taxAmount,
|
'tax_amount' => $taxAmount,
|
||||||
'base_tax_amount' => $taxAmount,
|
'base_tax_amount' => $taxAmount,
|
||||||
'discount_amount' => 0,
|
'discount_amount' => 0,
|
||||||
'base_discount_amount' => 0,
|
'base_discount_amount' => 0,
|
||||||
'order_id' => $attributes['order_id'],
|
'order_id' => $attributes['order_id'],
|
||||||
'order_address_id' => $attributes['order_address_id'],
|
'order_address_id' => $attributes['order_address_id'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ class InvoiceItemFactory extends Factory
|
||||||
public function definition(): array
|
public function definition(): array
|
||||||
{
|
{
|
||||||
$basePrice = $this->faker->randomFloat(2);
|
$basePrice = $this->faker->randomFloat(2);
|
||||||
$quantity = $this->faker->randomNumber();
|
$quantity = $this->faker->randomNumber();
|
||||||
|
|
||||||
if (!isset($attributes['order_item_id'])) {
|
if (!isset($attributes['order_item_id'])) {
|
||||||
$attributes['order_item_id'] = OrderItem::factory();
|
$attributes['order_item_id'] = OrderItem::factory();
|
||||||
|
|
@ -34,19 +34,19 @@ class InvoiceItemFactory extends Factory
|
||||||
->find($attributes['order_item_id']);
|
->find($attributes['order_item_id']);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'name' => $this->faker->word,
|
'name' => $this->faker->word,
|
||||||
'sku' => $this->faker->unique()->ean13,
|
'sku' => $this->faker->unique()->ean13,
|
||||||
'qty' => $quantity,
|
'qty' => $quantity,
|
||||||
'price' => $basePrice,
|
'price' => $basePrice,
|
||||||
'base_price' => $basePrice,
|
'base_price' => $basePrice,
|
||||||
'total' => $quantity * $basePrice,
|
'total' => $quantity * $basePrice,
|
||||||
'base_total' => $quantity * $basePrice,
|
'base_total' => $quantity * $basePrice,
|
||||||
'tax_amount' => 0,
|
'tax_amount' => 0,
|
||||||
'base_tax_amount' => 0,
|
'base_tax_amount' => 0,
|
||||||
'product_id' => $orderItem->product_id,
|
'product_id' => $orderItem->product_id,
|
||||||
'product_type' => $orderItem->product_type,
|
'product_type' => $orderItem->product_type,
|
||||||
'order_item_id' => $attributes['order_item_id'],
|
'order_item_id' => $attributes['order_item_id'],
|
||||||
'invoice_id' => Invoice::factory(),
|
'invoice_id' => Invoice::factory(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,23 +31,23 @@ class OrderAddressFactory extends Factory
|
||||||
*/
|
*/
|
||||||
public function definition(): array
|
public function definition(): array
|
||||||
{
|
{
|
||||||
$customer = Customer::factory()
|
$customer = Customer::factory()
|
||||||
->create();
|
->create();
|
||||||
$customerAddress = CustomerAddress::factory()
|
$customerAddress = CustomerAddress::factory()
|
||||||
->make();
|
->make();
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'first_name' => $customer->first_name,
|
'first_name' => $customer->first_name,
|
||||||
'last_name' => $customer->last_name,
|
'last_name' => $customer->last_name,
|
||||||
'email' => $customer->email,
|
'email' => $customer->email,
|
||||||
'address1' => $customerAddress->address1,
|
'address1' => $customerAddress->address1,
|
||||||
'country' => $customerAddress->country,
|
'country' => $customerAddress->country,
|
||||||
'state' => $customerAddress->state,
|
'state' => $customerAddress->state,
|
||||||
'city' => $customerAddress->city,
|
'city' => $customerAddress->city,
|
||||||
'postcode' => $customerAddress->postcode,
|
'postcode' => $customerAddress->postcode,
|
||||||
'phone' => $customerAddress->phone,
|
'phone' => $customerAddress->phone,
|
||||||
'address_type' => OrderAddress::ADDRESS_TYPE_BILLING,
|
'address_type' => OrderAddress::ADDRESS_TYPE_BILLING,
|
||||||
'order_id' => Order::factory(),
|
'order_id' => Order::factory(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,38 +43,38 @@ class OrderFactory extends Factory
|
||||||
->create();
|
->create();
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'increment_id' => $lastOrder + 1,
|
'increment_id' => $lastOrder + 1,
|
||||||
'status' => 'pending',
|
'status' => 'pending',
|
||||||
'channel_name' => 'Default',
|
'channel_name' => 'Default',
|
||||||
'is_guest' => 0,
|
'is_guest' => 0,
|
||||||
'customer_id' => $customer->id,
|
'customer_id' => $customer->id,
|
||||||
'customer_email' => $customer->email,
|
'customer_email' => $customer->email,
|
||||||
'customer_first_name' => $customer->first_name,
|
'customer_first_name' => $customer->first_name,
|
||||||
'customer_last_name' => $customer->last_name,
|
'customer_last_name' => $customer->last_name,
|
||||||
'is_gift' => 0,
|
'is_gift' => 0,
|
||||||
'total_item_count' => 1,
|
'total_item_count' => 1,
|
||||||
'total_qty_ordered' => 1,
|
'total_qty_ordered' => 1,
|
||||||
'base_currency_code' => 'EUR',
|
'base_currency_code' => 'EUR',
|
||||||
'channel_currency_code' => 'EUR',
|
'channel_currency_code' => 'EUR',
|
||||||
'order_currency_code' => 'EUR',
|
'order_currency_code' => 'EUR',
|
||||||
'grand_total' => 0.0000,
|
'grand_total' => 0.0000,
|
||||||
'base_grand_total' => 0.0000,
|
'base_grand_total' => 0.0000,
|
||||||
'grand_total_invoiced' => 0.0000,
|
'grand_total_invoiced' => 0.0000,
|
||||||
'base_grand_total_invoiced' => 0.0000,
|
'base_grand_total_invoiced' => 0.0000,
|
||||||
'grand_total_refunded' => 0.0000,
|
'grand_total_refunded' => 0.0000,
|
||||||
'base_grand_total_refunded' => 0.0000,
|
'base_grand_total_refunded' => 0.0000,
|
||||||
'sub_total' => 0.0000,
|
'sub_total' => 0.0000,
|
||||||
'base_sub_total' => 0.0000,
|
'base_sub_total' => 0.0000,
|
||||||
'sub_total_invoiced' => 0.0000,
|
'sub_total_invoiced' => 0.0000,
|
||||||
'base_sub_total_invoiced' => 0.0000,
|
'base_sub_total_invoiced' => 0.0000,
|
||||||
'sub_total_refunded' => 0.0000,
|
'sub_total_refunded' => 0.0000,
|
||||||
'base_sub_total_refunded' => 0.0000,
|
'base_sub_total_refunded' => 0.0000,
|
||||||
'customer_type' => Customer::class,
|
'customer_type' => Customer::class,
|
||||||
'channel_id' => 1,
|
'channel_id' => 1,
|
||||||
'channel_type' => Channel::class,
|
'channel_type' => Channel::class,
|
||||||
'cart_id' => 0,
|
'cart_id' => 0,
|
||||||
'shipping_method' => 'free_free',
|
'shipping_method' => 'free_free',
|
||||||
'shipping_title' => 'Free Shipping',
|
'shipping_title' => 'Free Shipping',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,23 +38,23 @@ class OrderItemFactory extends Factory
|
||||||
$fallbackPrice = $this->faker->randomFloat(4, 0, 1000);
|
$fallbackPrice = $this->faker->randomFloat(4, 0, 1000);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'sku' => $product->sku,
|
'sku' => $product->sku,
|
||||||
'type' => $product->type,
|
'type' => $product->type,
|
||||||
'name' => $product->name,
|
'name' => $product->name,
|
||||||
'price' => $product->price ?? $fallbackPrice,
|
'price' => $product->price ?? $fallbackPrice,
|
||||||
'base_price' => $product->price ?? $fallbackPrice,
|
'base_price' => $product->price ?? $fallbackPrice,
|
||||||
'total' => $product->price ?? $fallbackPrice,
|
'total' => $product->price ?? $fallbackPrice,
|
||||||
'base_total' => $product->price ?? $fallbackPrice,
|
'base_total' => $product->price ?? $fallbackPrice,
|
||||||
'product_id' => $product->id,
|
'product_id' => $product->id,
|
||||||
'qty_ordered' => 1,
|
'qty_ordered' => 1,
|
||||||
'qty_shipped' => 0,
|
'qty_shipped' => 0,
|
||||||
'qty_invoiced' => 0,
|
'qty_invoiced' => 0,
|
||||||
'qty_canceled' => 0,
|
'qty_canceled' => 0,
|
||||||
'qty_refunded' => 0,
|
'qty_refunded' => 0,
|
||||||
'additional' => [],
|
'additional' => [],
|
||||||
'order_id' => Order::factory(),
|
'order_id' => Order::factory(),
|
||||||
'created_at' => $now,
|
'created_at' => $now,
|
||||||
'updated_at' => $now,
|
'updated_at' => $now,
|
||||||
'product_type' => Product::class,
|
'product_type' => Product::class,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,9 +27,9 @@ class ShipmentFactory extends Factory
|
||||||
->create();
|
->create();
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'total_qty' => $this->faker->numberBetween(1, 20),
|
'total_qty' => $this->faker->numberBetween(1, 20),
|
||||||
'order_id' => $address->order_id,
|
'order_id' => $address->order_id,
|
||||||
'order_address_id' => $address->id,
|
'order_address_id' => $address->id,
|
||||||
'inventory_source_id' => InventorySource::factory(),
|
'inventory_source_id' => InventorySource::factory(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,8 @@ class Invoice extends Model implements InvoiceContract
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $statusLabel = [
|
protected $statusLabel = [
|
||||||
'pending' => 'Pending',
|
'pending' => 'Pending',
|
||||||
'paid' => 'Paid',
|
'paid' => 'Paid',
|
||||||
'refunded' => 'Refunded',
|
'refunded' => 'Refunded',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,10 @@ use Webkul\Checkout\Models\CartProxy;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Webkul\Sales\Contracts\Order as OrderContract;
|
use Webkul\Sales\Contracts\Order as OrderContract;
|
||||||
use Webkul\Sales\Database\Factories\OrderFactory;
|
use Webkul\Sales\Database\Factories\OrderFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
|
||||||
class Order extends Model implements OrderContract
|
class Order extends Model implements OrderContract
|
||||||
|
|
@ -39,13 +43,13 @@ class Order extends Model implements OrderContract
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $statusLabel = [
|
protected $statusLabel = [
|
||||||
self::STATUS_PENDING => 'Pending',
|
self::STATUS_PENDING => 'Pending',
|
||||||
self::STATUS_PENDING_PAYMENT => 'Pending Payment',
|
self::STATUS_PENDING_PAYMENT => 'Pending Payment',
|
||||||
self::STATUS_PROCESSING => 'Processing',
|
self::STATUS_PROCESSING => 'Processing',
|
||||||
self::STATUS_COMPLETED => 'Completed',
|
self::STATUS_COMPLETED => 'Completed',
|
||||||
self::STATUS_CANCELED => 'Canceled',
|
self::STATUS_CANCELED => 'Canceled',
|
||||||
self::STATUS_CLOSED => 'Closed',
|
self::STATUS_CLOSED => 'Closed',
|
||||||
self::STATUS_FRAUD => 'Fraud',
|
self::STATUS_FRAUD => 'Fraud',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -83,7 +87,7 @@ class Order extends Model implements OrderContract
|
||||||
/**
|
/**
|
||||||
* Get the associated cart that was used to create this order.
|
* Get the associated cart that was used to create this order.
|
||||||
*/
|
*/
|
||||||
public function cart(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
public function cart(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(CartProxy::modelClass());
|
return $this->belongsTo(CartProxy::modelClass());
|
||||||
}
|
}
|
||||||
|
|
@ -91,7 +95,7 @@ class Order extends Model implements OrderContract
|
||||||
/**
|
/**
|
||||||
* Get the order items record associated with the order.
|
* Get the order items record associated with the order.
|
||||||
*/
|
*/
|
||||||
public function items(): \Illuminate\Database\Eloquent\Relations\HasMany
|
public function items(): HasMany
|
||||||
{
|
{
|
||||||
return $this->hasMany(OrderItemProxy::modelClass())
|
return $this->hasMany(OrderItemProxy::modelClass())
|
||||||
->whereNull('parent_id');
|
->whereNull('parent_id');
|
||||||
|
|
@ -100,7 +104,7 @@ class Order extends Model implements OrderContract
|
||||||
/**
|
/**
|
||||||
* Get the comments record associated with the order.
|
* Get the comments record associated with the order.
|
||||||
*/
|
*/
|
||||||
public function comments(): \Illuminate\Database\Eloquent\Relations\HasMany
|
public function comments(): HasMany
|
||||||
{
|
{
|
||||||
return $this->hasMany(OrderCommentProxy::modelClass());
|
return $this->hasMany(OrderCommentProxy::modelClass());
|
||||||
}
|
}
|
||||||
|
|
@ -108,7 +112,7 @@ class Order extends Model implements OrderContract
|
||||||
/**
|
/**
|
||||||
* Get the order items record associated with the order.
|
* Get the order items record associated with the order.
|
||||||
*/
|
*/
|
||||||
public function all_items(): \Illuminate\Database\Eloquent\Relations\HasMany
|
public function all_items(): HasMany
|
||||||
{
|
{
|
||||||
return $this->hasMany(OrderItemProxy::modelClass());
|
return $this->hasMany(OrderItemProxy::modelClass());
|
||||||
}
|
}
|
||||||
|
|
@ -116,7 +120,7 @@ class Order extends Model implements OrderContract
|
||||||
/**
|
/**
|
||||||
* Get the order shipments record associated with the order.
|
* Get the order shipments record associated with the order.
|
||||||
*/
|
*/
|
||||||
public function shipments(): \Illuminate\Database\Eloquent\Relations\HasMany
|
public function shipments(): HasMany
|
||||||
{
|
{
|
||||||
return $this->hasMany(ShipmentProxy::modelClass());
|
return $this->hasMany(ShipmentProxy::modelClass());
|
||||||
}
|
}
|
||||||
|
|
@ -124,7 +128,7 @@ class Order extends Model implements OrderContract
|
||||||
/**
|
/**
|
||||||
* Get the order invoices record associated with the order.
|
* Get the order invoices record associated with the order.
|
||||||
*/
|
*/
|
||||||
public function invoices(): \Illuminate\Database\Eloquent\Relations\HasMany
|
public function invoices(): HasMany
|
||||||
{
|
{
|
||||||
return $this->hasMany(InvoiceProxy::modelClass());
|
return $this->hasMany(InvoiceProxy::modelClass());
|
||||||
}
|
}
|
||||||
|
|
@ -132,7 +136,7 @@ class Order extends Model implements OrderContract
|
||||||
/**
|
/**
|
||||||
* Get the order refunds record associated with the order.
|
* Get the order refunds record associated with the order.
|
||||||
*/
|
*/
|
||||||
public function refunds(): \Illuminate\Database\Eloquent\Relations\HasMany
|
public function refunds(): HasMany
|
||||||
{
|
{
|
||||||
return $this->hasMany(RefundProxy::modelClass());
|
return $this->hasMany(RefundProxy::modelClass());
|
||||||
}
|
}
|
||||||
|
|
@ -140,7 +144,7 @@ class Order extends Model implements OrderContract
|
||||||
/**
|
/**
|
||||||
* Get the order transactions record associated with the order.
|
* Get the order transactions record associated with the order.
|
||||||
*/
|
*/
|
||||||
public function transactions(): \Illuminate\Database\Eloquent\Relations\HasMany
|
public function transactions(): HasMany
|
||||||
{
|
{
|
||||||
return $this->hasMany(OrderTransactionProxy::modelClass());
|
return $this->hasMany(OrderTransactionProxy::modelClass());
|
||||||
}
|
}
|
||||||
|
|
@ -148,7 +152,7 @@ class Order extends Model implements OrderContract
|
||||||
/**
|
/**
|
||||||
* Get the customer record associated with the order.
|
* Get the customer record associated with the order.
|
||||||
*/
|
*/
|
||||||
public function customer(): \Illuminate\Database\Eloquent\Relations\MorphTo
|
public function customer(): MorphTo
|
||||||
{
|
{
|
||||||
return $this->morphTo();
|
return $this->morphTo();
|
||||||
}
|
}
|
||||||
|
|
@ -156,7 +160,7 @@ class Order extends Model implements OrderContract
|
||||||
/**
|
/**
|
||||||
* Get the addresses for the order.
|
* Get the addresses for the order.
|
||||||
*/
|
*/
|
||||||
public function addresses(): \Illuminate\Database\Eloquent\Relations\HasMany
|
public function addresses(): HasMany
|
||||||
{
|
{
|
||||||
return $this->hasMany(OrderAddressProxy::modelClass());
|
return $this->hasMany(OrderAddressProxy::modelClass());
|
||||||
}
|
}
|
||||||
|
|
@ -164,7 +168,7 @@ class Order extends Model implements OrderContract
|
||||||
/**
|
/**
|
||||||
* Get the payment for the order.
|
* Get the payment for the order.
|
||||||
*/
|
*/
|
||||||
public function payment(): \Illuminate\Database\Eloquent\Relations\HasOne
|
public function payment(): HasOne
|
||||||
{
|
{
|
||||||
return $this->hasOne(OrderPaymentProxy::modelClass());
|
return $this->hasOne(OrderPaymentProxy::modelClass());
|
||||||
}
|
}
|
||||||
|
|
@ -172,7 +176,7 @@ class Order extends Model implements OrderContract
|
||||||
/**
|
/**
|
||||||
* Get the billing address for the order.
|
* Get the billing address for the order.
|
||||||
*/
|
*/
|
||||||
public function billing_address(): \Illuminate\Database\Eloquent\Relations\HasMany
|
public function billing_address(): HasMany
|
||||||
{
|
{
|
||||||
return $this->addresses()
|
return $this->addresses()
|
||||||
->where('address_type', OrderAddress::ADDRESS_TYPE_BILLING);
|
->where('address_type', OrderAddress::ADDRESS_TYPE_BILLING);
|
||||||
|
|
@ -190,7 +194,7 @@ class Order extends Model implements OrderContract
|
||||||
/**
|
/**
|
||||||
* Get the shipping address for the order.
|
* Get the shipping address for the order.
|
||||||
*/
|
*/
|
||||||
public function shipping_address(): \Illuminate\Database\Eloquent\Relations\HasMany
|
public function shipping_address(): HasMany
|
||||||
{
|
{
|
||||||
return $this->addresses()
|
return $this->addresses()
|
||||||
->where('address_type', OrderAddress::ADDRESS_TYPE_SHIPPING);
|
->where('address_type', OrderAddress::ADDRESS_TYPE_SHIPPING);
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ class OrderItem extends Model implements OrderItemContract
|
||||||
return $this->typeInstance;
|
return $this->typeInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->typeInstance = app(config('product_types.'.$this->type.'.class'));
|
$this->typeInstance = app(config('product_types.' . $this->type . '.class'));
|
||||||
|
|
||||||
if ($this->product) {
|
if ($this->product) {
|
||||||
$this->typeInstance->setProduct($this);
|
$this->typeInstance->setProduct($this);
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,9 @@ use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
class SalesServiceProvider extends ServiceProvider
|
class SalesServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
|
|
||||||
public function boot(): void
|
public function boot(): void
|
||||||
{
|
{
|
||||||
$this->loadMigrationsFrom(__DIR__.'/../Database/Migrations');
|
$this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -19,7 +18,6 @@ class SalesServiceProvider extends ServiceProvider
|
||||||
*/
|
*/
|
||||||
public function register(): void
|
public function register(): void
|
||||||
{
|
{
|
||||||
$this->mergeConfigFrom(dirname(__DIR__).'/Config/system.php', 'core');
|
$this->mergeConfigFrom(dirname(__DIR__) . '/Config/system.php', 'core');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -22,8 +22,8 @@ class TaxCategoryFactory extends Factory
|
||||||
public function definition(): array
|
public function definition(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'code' => $this->faker->uuid,
|
'code' => $this->faker->uuid,
|
||||||
'name' => $this->faker->words(2, true),
|
'name' => $this->faker->words(2, true),
|
||||||
'description' => $this->faker->sentence(10),
|
'description' => $this->faker->sentence(10),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ class TaxMapFactory extends Factory
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'tax_category_id' => TaxCategory::factory(),
|
'tax_category_id' => TaxCategory::factory(),
|
||||||
'tax_rate_id' => TaxRate::factory(),
|
'tax_rate_id' => TaxRate::factory(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,13 +23,13 @@ class TaxRateFactory extends Factory
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'identifier' => $this->faker->uuid,
|
'identifier' => $this->faker->uuid,
|
||||||
'is_zip' => 0,
|
'is_zip' => 0,
|
||||||
'zip_code' => '*',
|
'zip_code' => '*',
|
||||||
'zip_from' => null,
|
'zip_from' => null,
|
||||||
'zip_to' => null,
|
'zip_to' => null,
|
||||||
'state' => '',
|
'state' => '',
|
||||||
'country' => $this->faker->countryCode,
|
'country' => $this->faker->countryCode,
|
||||||
'tax_rate' => $this->faker->randomFloat(2, 3, 25),
|
'tax_rate' => $this->faker->randomFloat(2, 3, 25),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -38,7 +38,7 @@ class DatabaseLogicCest
|
||||||
public function testGetUrlPathOfCategory(UnitTester $I)
|
public function testGetUrlPathOfCategory(UnitTester $I)
|
||||||
{
|
{
|
||||||
$rootCategoryTranslation = $I->grabRecord(CategoryTranslation::class, [
|
$rootCategoryTranslation = $I->grabRecord(CategoryTranslation::class, [
|
||||||
'slug' => 'root',
|
'slug' => 'root',
|
||||||
'locale' => 'en',
|
'locale' => 'en',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
@ -49,20 +49,20 @@ class DatabaseLogicCest
|
||||||
$parentCategoryName = $this->faker->word;
|
$parentCategoryName = $this->faker->word;
|
||||||
|
|
||||||
$parentCategoryAttributes = [
|
$parentCategoryAttributes = [
|
||||||
'parent_id' => $rootCategory->id,
|
'parent_id' => $rootCategory->id,
|
||||||
'position' => 1,
|
'position' => 1,
|
||||||
'status' => 1,
|
'status' => 1,
|
||||||
$this->localeEn->code => [
|
$this->localeEn->code => [
|
||||||
'name' => $parentCategoryName,
|
'name' => $parentCategoryName,
|
||||||
'slug' => strtolower($parentCategoryName),
|
'slug' => strtolower($parentCategoryName),
|
||||||
'description' => $parentCategoryName,
|
'description' => $parentCategoryName,
|
||||||
'locale_id' => $this->localeEn->id,
|
'locale_id' => $this->localeEn->id,
|
||||||
],
|
],
|
||||||
$this->localeDe->code => [
|
$this->localeDe->code => [
|
||||||
'name' => $parentCategoryName,
|
'name' => $parentCategoryName,
|
||||||
'slug' => strtolower($parentCategoryName),
|
'slug' => strtolower($parentCategoryName),
|
||||||
'description' => $parentCategoryName,
|
'description' => $parentCategoryName,
|
||||||
'locale_id' => $this->localeDe->id,
|
'locale_id' => $this->localeDe->id,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
@ -71,22 +71,22 @@ class DatabaseLogicCest
|
||||||
$rootCategory->prependNode($parentCategory);
|
$rootCategory->prependNode($parentCategory);
|
||||||
$I->assertNotNull($parentCategory);
|
$I->assertNotNull($parentCategory);
|
||||||
|
|
||||||
$categoryName = $this->faker->word;
|
$categoryName = $this->faker->word;
|
||||||
$categoryAttributes = [
|
$categoryAttributes = [
|
||||||
'position' => 1,
|
'position' => 1,
|
||||||
'status' => 1,
|
'status' => 1,
|
||||||
'parent_id' => $parentCategory->id,
|
'parent_id' => $parentCategory->id,
|
||||||
$this->localeEn->code => [
|
$this->localeEn->code => [
|
||||||
'name' => $categoryName,
|
'name' => $categoryName,
|
||||||
'slug' => strtolower($categoryName),
|
'slug' => strtolower($categoryName),
|
||||||
'description' => $categoryName,
|
'description' => $categoryName,
|
||||||
'locale_id' => $this->localeEn->id,
|
'locale_id' => $this->localeEn->id,
|
||||||
],
|
],
|
||||||
$this->localeDe->code => [
|
$this->localeDe->code => [
|
||||||
'name' => $categoryName,
|
'name' => $categoryName,
|
||||||
'slug' => strtolower($categoryName),
|
'slug' => strtolower($categoryName),
|
||||||
'description' => $categoryName,
|
'description' => $categoryName,
|
||||||
'locale_id' => $this->localeDe->id,
|
'locale_id' => $this->localeDe->id,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
@ -114,14 +114,14 @@ class DatabaseLogicCest
|
||||||
$I->assertEquals($expectedUrlPath, $urlPathQueryResult->url_path);
|
$I->assertEquals($expectedUrlPath, $urlPathQueryResult->url_path);
|
||||||
|
|
||||||
$root2Category = $I->make(Category::class, [
|
$root2Category = $I->make(Category::class, [
|
||||||
'position' => 1,
|
'position' => 1,
|
||||||
'status' => 1,
|
'status' => 1,
|
||||||
'parent_id' => null,
|
'parent_id' => null,
|
||||||
$this->localeEn->code => [
|
$this->localeEn->code => [
|
||||||
'name' => $this->faker->word,
|
'name' => $this->faker->word,
|
||||||
'slug' => strtolower($this->faker->word),
|
'slug' => strtolower($this->faker->word),
|
||||||
'description' => $this->faker->word,
|
'description' => $this->faker->word,
|
||||||
'locale_id' => $this->localeEn->id,
|
'locale_id' => $this->localeEn->id,
|
||||||
],
|
],
|
||||||
])
|
])
|
||||||
->first();
|
->first();
|
||||||
|
|
|
||||||
|
|
@ -48,16 +48,16 @@ class TriggerCest
|
||||||
$this->faker = Factory::create();
|
$this->faker = Factory::create();
|
||||||
|
|
||||||
$rootCategoryTranslation = $I->grabRecord(CategoryTranslation::class, [
|
$rootCategoryTranslation = $I->grabRecord(CategoryTranslation::class, [
|
||||||
'slug' => 'root',
|
'slug' => 'root',
|
||||||
'locale' => 'en',
|
'locale' => 'en',
|
||||||
]);
|
]);
|
||||||
$rootCategory = $I->grabRecord(Category::class, [
|
$rootCategory = $I->grabRecord(Category::class, [
|
||||||
'id' => $rootCategoryTranslation->category_id,
|
'id' => $rootCategoryTranslation->category_id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->parentCategoryName = $this->faker->word;
|
$this->parentCategoryName = $this->faker->word;
|
||||||
$this->categoryName = $this->faker->word . $this->faker->randomDigit;
|
$this->categoryName = $this->faker->word . $this->faker->randomDigit;
|
||||||
$this->root2CategoryName = $this->faker->word . $this->faker->randomDigit;
|
$this->root2CategoryName = $this->faker->word . $this->faker->randomDigit;
|
||||||
$this->childOfRoot2CategoryName = $this->faker->word . $this->faker->randomDigit;
|
$this->childOfRoot2CategoryName = $this->faker->word . $this->faker->randomDigit;
|
||||||
|
|
||||||
$this->localeEn = $I->grabRecord(Locale::class, [
|
$this->localeEn = $I->grabRecord(Locale::class, [
|
||||||
|
|
@ -69,20 +69,20 @@ class TriggerCest
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->parentCategoryAttributes = [
|
$this->parentCategoryAttributes = [
|
||||||
'parent_id' => $rootCategory->id,
|
'parent_id' => $rootCategory->id,
|
||||||
'position' => 1,
|
'position' => 1,
|
||||||
'status' => 1,
|
'status' => 1,
|
||||||
$this->localeEn->code => [
|
$this->localeEn->code => [
|
||||||
'name' => $this->parentCategoryName,
|
'name' => $this->parentCategoryName,
|
||||||
'slug' => strtolower($this->parentCategoryName),
|
'slug' => strtolower($this->parentCategoryName),
|
||||||
'description' => $this->parentCategoryName,
|
'description' => $this->parentCategoryName,
|
||||||
'locale_id' => $this->localeEn->id,
|
'locale_id' => $this->localeEn->id,
|
||||||
],
|
],
|
||||||
$this->localeDe->code => [
|
$this->localeDe->code => [
|
||||||
'name' => $this->parentCategoryName,
|
'name' => $this->parentCategoryName,
|
||||||
'slug' => strtolower($this->parentCategoryName),
|
'slug' => strtolower($this->parentCategoryName),
|
||||||
'description' => $this->parentCategoryName,
|
'description' => $this->parentCategoryName,
|
||||||
'locale_id' => $this->localeDe->id,
|
'locale_id' => $this->localeDe->id,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
@ -92,20 +92,20 @@ class TriggerCest
|
||||||
$I->assertNotNull($this->parentCategory);
|
$I->assertNotNull($this->parentCategory);
|
||||||
|
|
||||||
$this->categoryAttributes = [
|
$this->categoryAttributes = [
|
||||||
'position' => 1,
|
'position' => 1,
|
||||||
'status' => 1,
|
'status' => 1,
|
||||||
'parent_id' => $this->parentCategory->id,
|
'parent_id' => $this->parentCategory->id,
|
||||||
$this->localeEn->code => [
|
$this->localeEn->code => [
|
||||||
'name' => $this->categoryName,
|
'name' => $this->categoryName,
|
||||||
'slug' => strtolower($this->categoryName),
|
'slug' => strtolower($this->categoryName),
|
||||||
'description' => $this->categoryName,
|
'description' => $this->categoryName,
|
||||||
'locale_id' => $this->localeEn->id,
|
'locale_id' => $this->localeEn->id,
|
||||||
],
|
],
|
||||||
$this->localeDe->code => [
|
$this->localeDe->code => [
|
||||||
'name' => $this->categoryName,
|
'name' => $this->categoryName,
|
||||||
'slug' => strtolower($this->categoryName),
|
'slug' => strtolower($this->categoryName),
|
||||||
'description' => $this->categoryName,
|
'description' => $this->categoryName,
|
||||||
'locale_id' => $this->localeDe->id,
|
'locale_id' => $this->localeDe->id,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
@ -116,20 +116,20 @@ class TriggerCest
|
||||||
|
|
||||||
|
|
||||||
$this->root2CategoryAttributes = [
|
$this->root2CategoryAttributes = [
|
||||||
'position' => 1,
|
'position' => 1,
|
||||||
'status' => 1,
|
'status' => 1,
|
||||||
'parent_id' => null,
|
'parent_id' => null,
|
||||||
$this->localeEn->code => [
|
$this->localeEn->code => [
|
||||||
'name' => $this->root2CategoryName,
|
'name' => $this->root2CategoryName,
|
||||||
'slug' => strtolower($this->root2CategoryName),
|
'slug' => strtolower($this->root2CategoryName),
|
||||||
'description' => $this->root2CategoryName,
|
'description' => $this->root2CategoryName,
|
||||||
'locale_id' => $this->localeEn->id,
|
'locale_id' => $this->localeEn->id,
|
||||||
],
|
],
|
||||||
$this->localeDe->code => [
|
$this->localeDe->code => [
|
||||||
'name' => $this->root2CategoryName,
|
'name' => $this->root2CategoryName,
|
||||||
'slug' => strtolower($this->root2CategoryName),
|
'slug' => strtolower($this->root2CategoryName),
|
||||||
'description' => $this->root2CategoryName,
|
'description' => $this->root2CategoryName,
|
||||||
'locale_id' => $this->localeDe->id,
|
'locale_id' => $this->localeDe->id,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
@ -142,20 +142,20 @@ class TriggerCest
|
||||||
$I->assertGreaterThan($rootCategory->_rgt, $this->root2Category->_lft);
|
$I->assertGreaterThan($rootCategory->_rgt, $this->root2Category->_lft);
|
||||||
|
|
||||||
$this->childOfRoot2CategoryAttributes = [
|
$this->childOfRoot2CategoryAttributes = [
|
||||||
'position' => 1,
|
'position' => 1,
|
||||||
'status' => 1,
|
'status' => 1,
|
||||||
'parent_id' => $this->root2Category->id,
|
'parent_id' => $this->root2Category->id,
|
||||||
$this->localeEn->code => [
|
$this->localeEn->code => [
|
||||||
'name' => $this->childOfRoot2CategoryName,
|
'name' => $this->childOfRoot2CategoryName,
|
||||||
'slug' => strtolower($this->childOfRoot2CategoryName),
|
'slug' => strtolower($this->childOfRoot2CategoryName),
|
||||||
'description' => $this->childOfRoot2CategoryName,
|
'description' => $this->childOfRoot2CategoryName,
|
||||||
'locale_id' => $this->localeEn->id,
|
'locale_id' => $this->localeEn->id,
|
||||||
],
|
],
|
||||||
$this->localeDe->code => [
|
$this->localeDe->code => [
|
||||||
'name' => $this->childOfRoot2CategoryName,
|
'name' => $this->childOfRoot2CategoryName,
|
||||||
'slug' => strtolower($this->childOfRoot2CategoryName),
|
'slug' => strtolower($this->childOfRoot2CategoryName),
|
||||||
'description' => $this->childOfRoot2CategoryName,
|
'description' => $this->childOfRoot2CategoryName,
|
||||||
'locale_id' => $this->localeDe->id,
|
'locale_id' => $this->localeDe->id,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
@ -170,47 +170,47 @@ class TriggerCest
|
||||||
{
|
{
|
||||||
$I->seeRecord(CategoryTranslation::class, [
|
$I->seeRecord(CategoryTranslation::class, [
|
||||||
'category_id' => $this->parentCategory->id,
|
'category_id' => $this->parentCategory->id,
|
||||||
'name' => $this->parentCategoryName,
|
'name' => $this->parentCategoryName,
|
||||||
'locale' => $this->localeEn->code,
|
'locale' => $this->localeEn->code,
|
||||||
'url_path' => strtolower($this->parentCategoryName),
|
'url_path' => strtolower($this->parentCategoryName),
|
||||||
]);
|
]);
|
||||||
$I->seeRecord(CategoryTranslation::class, [
|
$I->seeRecord(CategoryTranslation::class, [
|
||||||
'category_id' => $this->parentCategory->id,
|
'category_id' => $this->parentCategory->id,
|
||||||
'name' => $this->parentCategoryName,
|
'name' => $this->parentCategoryName,
|
||||||
'locale' => $this->localeDe->code,
|
'locale' => $this->localeDe->code,
|
||||||
'url_path' => strtolower($this->parentCategoryName),
|
'url_path' => strtolower($this->parentCategoryName),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$I->seeRecord(CategoryTranslation::class, [
|
$I->seeRecord(CategoryTranslation::class, [
|
||||||
'category_id' => $this->category->id,
|
'category_id' => $this->category->id,
|
||||||
'name' => $this->categoryName,
|
'name' => $this->categoryName,
|
||||||
'locale' => $this->localeEn->code,
|
'locale' => $this->localeEn->code,
|
||||||
'url_path' => strtolower($this->parentCategoryName) . '/' . strtolower($this->categoryName),
|
'url_path' => strtolower($this->parentCategoryName) . '/' . strtolower($this->categoryName),
|
||||||
]);
|
]);
|
||||||
$I->seeRecord(CategoryTranslation::class, [
|
$I->seeRecord(CategoryTranslation::class, [
|
||||||
'category_id' => $this->category->id,
|
'category_id' => $this->category->id,
|
||||||
'name' => $this->categoryName,
|
'name' => $this->categoryName,
|
||||||
'locale' => $this->localeDe->code,
|
'locale' => $this->localeDe->code,
|
||||||
'url_path' => strtolower($this->parentCategoryName) . '/' . strtolower($this->categoryName),
|
'url_path' => strtolower($this->parentCategoryName) . '/' . strtolower($this->categoryName),
|
||||||
]);
|
]);
|
||||||
$I->seeRecord(CategoryTranslation::class, [
|
$I->seeRecord(CategoryTranslation::class, [
|
||||||
'category_id' => $this->root2Category->id,
|
'category_id' => $this->root2Category->id,
|
||||||
'name' => $this->root2CategoryName,
|
'name' => $this->root2CategoryName,
|
||||||
'locale' => $this->localeEn->code,
|
'locale' => $this->localeEn->code,
|
||||||
'url_path' => '',
|
'url_path' => '',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$I->seeRecord(CategoryTranslation::class, [
|
$I->seeRecord(CategoryTranslation::class, [
|
||||||
'category_id' => $this->childOfRoot2Category->id,
|
'category_id' => $this->childOfRoot2Category->id,
|
||||||
'name' => $this->childOfRoot2CategoryName,
|
'name' => $this->childOfRoot2CategoryName,
|
||||||
'locale' => $this->localeDe->code,
|
'locale' => $this->localeDe->code,
|
||||||
'url_path' => strtolower($this->childOfRoot2CategoryName),
|
'url_path' => strtolower($this->childOfRoot2CategoryName),
|
||||||
]);
|
]);
|
||||||
$I->seeRecord(CategoryTranslation::class, [
|
$I->seeRecord(CategoryTranslation::class, [
|
||||||
'category_id' => $this->childOfRoot2Category->id,
|
'category_id' => $this->childOfRoot2Category->id,
|
||||||
'name' => $this->childOfRoot2CategoryName,
|
'name' => $this->childOfRoot2CategoryName,
|
||||||
'locale' => $this->localeEn->code,
|
'locale' => $this->localeEn->code,
|
||||||
'url_path' => strtolower($this->childOfRoot2CategoryName),
|
'url_path' => strtolower($this->childOfRoot2CategoryName),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -218,21 +218,21 @@ class TriggerCest
|
||||||
{
|
{
|
||||||
$I->seeRecord(CategoryTranslation::class, [
|
$I->seeRecord(CategoryTranslation::class, [
|
||||||
'category_id' => $this->category->id,
|
'category_id' => $this->category->id,
|
||||||
'name' => $this->categoryName,
|
'name' => $this->categoryName,
|
||||||
'slug' => strtolower($this->categoryName),
|
'slug' => strtolower($this->categoryName),
|
||||||
'locale' => $this->localeEn->code,
|
'locale' => $this->localeEn->code,
|
||||||
'url_path' => strtolower($this->parentCategoryName) . '/' . strtolower($this->categoryName),
|
'url_path' => strtolower($this->parentCategoryName) . '/' . strtolower($this->categoryName),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$I->seeRecord(CategoryTranslation::class, [
|
$I->seeRecord(CategoryTranslation::class, [
|
||||||
'category_id' => $this->category->id,
|
'category_id' => $this->category->id,
|
||||||
'name' => $this->categoryName,
|
'name' => $this->categoryName,
|
||||||
'slug' => strtolower($this->categoryName),
|
'slug' => strtolower($this->categoryName),
|
||||||
'locale' => $this->localeDe->code,
|
'locale' => $this->localeDe->code,
|
||||||
'url_path' => strtolower($this->parentCategoryName) . '/' . strtolower($this->categoryName),
|
'url_path' => strtolower($this->parentCategoryName) . '/' . strtolower($this->categoryName),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$newCategoryName = $this->faker->word;
|
$newCategoryName = $this->faker->word;
|
||||||
$this->categoryAttributes[$this->localeDe->code]['name'] = $newCategoryName;
|
$this->categoryAttributes[$this->localeDe->code]['name'] = $newCategoryName;
|
||||||
$this->categoryAttributes[$this->localeDe->code]['slug'] = strtolower($newCategoryName);
|
$this->categoryAttributes[$this->localeDe->code]['slug'] = strtolower($newCategoryName);
|
||||||
$I->assertTrue($this->category->update($this->categoryAttributes));
|
$I->assertTrue($this->category->update($this->categoryAttributes));
|
||||||
|
|
@ -240,18 +240,18 @@ class TriggerCest
|
||||||
|
|
||||||
$I->dontSeeRecord(CategoryTranslation::class, [
|
$I->dontSeeRecord(CategoryTranslation::class, [
|
||||||
'category_id' => $this->category->id,
|
'category_id' => $this->category->id,
|
||||||
'name' => $newCategoryName,
|
'name' => $newCategoryName,
|
||||||
'slug' => strtolower($this->categoryName),
|
'slug' => strtolower($this->categoryName),
|
||||||
'locale' => $this->localeEn->code,
|
'locale' => $this->localeEn->code,
|
||||||
'url_path' => strtolower($this->parentCategoryName) . '/' . strtolower($this->categoryName),
|
'url_path' => strtolower($this->parentCategoryName) . '/' . strtolower($this->categoryName),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$I->seeRecord(CategoryTranslation::class, [
|
$I->seeRecord(CategoryTranslation::class, [
|
||||||
'category_id' => $this->category->id,
|
'category_id' => $this->category->id,
|
||||||
'name' => $newCategoryName,
|
'name' => $newCategoryName,
|
||||||
'slug' => strtolower($newCategoryName),
|
'slug' => strtolower($newCategoryName),
|
||||||
'locale' => $this->localeDe->code,
|
'locale' => $this->localeDe->code,
|
||||||
'url_path' => strtolower($this->parentCategoryName) . '/' . strtolower($newCategoryName),
|
'url_path' => strtolower($this->parentCategoryName) . '/' . strtolower($newCategoryName),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -259,46 +259,46 @@ class TriggerCest
|
||||||
{
|
{
|
||||||
$I->seeRecord(CategoryTranslation::class, [
|
$I->seeRecord(CategoryTranslation::class, [
|
||||||
'category_id' => $this->parentCategory->id,
|
'category_id' => $this->parentCategory->id,
|
||||||
'name' => $this->parentCategoryName,
|
'name' => $this->parentCategoryName,
|
||||||
'slug' => strtolower($this->parentCategoryName),
|
'slug' => strtolower($this->parentCategoryName),
|
||||||
'locale' => $this->localeEn->code,
|
'locale' => $this->localeEn->code,
|
||||||
'url_path' => strtolower($this->parentCategoryName),
|
'url_path' => strtolower($this->parentCategoryName),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$I->seeRecord(CategoryTranslation::class, [
|
$I->seeRecord(CategoryTranslation::class, [
|
||||||
'category_id' => $this->category->id,
|
'category_id' => $this->category->id,
|
||||||
'name' => $this->categoryName,
|
'name' => $this->categoryName,
|
||||||
'slug' => strtolower($this->categoryName),
|
'slug' => strtolower($this->categoryName),
|
||||||
'locale' => $this->localeEn->code,
|
'locale' => $this->localeEn->code,
|
||||||
'url_path' => strtolower($this->parentCategoryName) . '/' . $this->categoryName,
|
'url_path' => strtolower($this->parentCategoryName) . '/' . $this->categoryName,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUpdateTriggersOnCategoriesTable(UnitTester $I)
|
public function testUpdateTriggersOnCategoriesTable(UnitTester $I)
|
||||||
{
|
{
|
||||||
$I->seeRecord(Category::class, [
|
$I->seeRecord(Category::class, [
|
||||||
'id' => $this->category->id,
|
'id' => $this->category->id,
|
||||||
'parent_id' => $this->parentCategory->id,
|
'parent_id' => $this->parentCategory->id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$I->seeRecord(CategoryTranslation::class, [
|
$I->seeRecord(CategoryTranslation::class, [
|
||||||
'category_id' => $this->category->id,
|
'category_id' => $this->category->id,
|
||||||
'name' => $this->categoryName,
|
'name' => $this->categoryName,
|
||||||
'slug' => strtolower($this->categoryName),
|
'slug' => strtolower($this->categoryName),
|
||||||
'locale' => $this->localeEn->code,
|
'locale' => $this->localeEn->code,
|
||||||
'url_path' => strtolower($this->parentCategoryName) . '/' . strtolower($this->categoryName),
|
'url_path' => strtolower($this->parentCategoryName) . '/' . strtolower($this->categoryName),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$category2Name = $this->faker->word;
|
$category2Name = $this->faker->word;
|
||||||
$category2Attributes = [
|
$category2Attributes = [
|
||||||
'position' => 1,
|
'position' => 1,
|
||||||
'status' => 1,
|
'status' => 1,
|
||||||
'parent_id' => $this->parentCategory->id,
|
'parent_id' => $this->parentCategory->id,
|
||||||
$this->localeEn->code => [
|
$this->localeEn->code => [
|
||||||
'name' => $category2Name,
|
'name' => $category2Name,
|
||||||
'slug' => strtolower($category2Name),
|
'slug' => strtolower($category2Name),
|
||||||
'description' => $category2Name,
|
'description' => $category2Name,
|
||||||
'locale_id' => $this->localeEn->id,
|
'locale_id' => $this->localeEn->id,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
@ -312,10 +312,10 @@ class TriggerCest
|
||||||
$expectedUrlPath = strtolower($this->parentCategoryName) . '/' . strtolower($category2Name) . '/' . strtolower($this->categoryName);
|
$expectedUrlPath = strtolower($this->parentCategoryName) . '/' . strtolower($category2Name) . '/' . strtolower($this->categoryName);
|
||||||
$I->seeRecord(CategoryTranslation::class, [
|
$I->seeRecord(CategoryTranslation::class, [
|
||||||
'category_id' => $this->category->id,
|
'category_id' => $this->category->id,
|
||||||
'name' => $this->categoryName,
|
'name' => $this->categoryName,
|
||||||
'slug' => strtolower($this->categoryName),
|
'slug' => strtolower($this->categoryName),
|
||||||
'locale' => $this->localeEn->code,
|
'locale' => $this->localeEn->code,
|
||||||
'url_path' => $expectedUrlPath,
|
'url_path' => $expectedUrlPath,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@ use Cart;
|
||||||
|
|
||||||
class cartRuleWithCoupon
|
class cartRuleWithCoupon
|
||||||
{
|
{
|
||||||
|
|
||||||
public $cartRule;
|
public $cartRule;
|
||||||
|
|
||||||
public $coupon;
|
public $coupon;
|
||||||
|
|
@ -33,14 +32,12 @@ class cartRuleWithCoupon
|
||||||
public function __construct(CartRule $cartRule, CartRuleCoupon $coupon)
|
public function __construct(CartRule $cartRule, CartRuleCoupon $coupon)
|
||||||
{
|
{
|
||||||
$this->cartRule = $cartRule;
|
$this->cartRule = $cartRule;
|
||||||
$this->coupon = $coupon;
|
$this->coupon = $coupon;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class expectedCartItem implements Arrayable
|
class expectedCartItem implements Arrayable
|
||||||
{
|
{
|
||||||
|
|
||||||
public const ITEM_DISCOUNT_AMOUNT_PRECISION = 4;
|
public const ITEM_DISCOUNT_AMOUNT_PRECISION = 4;
|
||||||
|
|
||||||
public const ITEM_TAX_AMOUNT_PRECISION = 4;
|
public const ITEM_TAX_AMOUNT_PRECISION = 4;
|
||||||
|
|
@ -77,65 +74,63 @@ class expectedCartItem implements Arrayable
|
||||||
|
|
||||||
public function __construct(int $cartId, int $productId)
|
public function __construct(int $cartId, int $productId)
|
||||||
{
|
{
|
||||||
$this->cart_id = $cartId;
|
$this->cart_id = $cartId;
|
||||||
$this->product_id = $productId;
|
$this->product_id = $productId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function calcTotals(): void
|
public function calcTotals(): void
|
||||||
{
|
{
|
||||||
$this->total = $this->quantity * $this->price;
|
$this->total = $this->quantity * $this->price;
|
||||||
$this->base_total = $this->quantity * $this->price;
|
$this->base_total = $this->quantity * $this->price;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function calcTaxAmounts(): void
|
public function calcTaxAmounts(): void
|
||||||
{
|
{
|
||||||
$this->tax_amount = round($this->quantity * $this->price * $this->tax_percent / 100, self::ITEM_TAX_AMOUNT_PRECISION);
|
$this->tax_amount = round($this->quantity * $this->price * $this->tax_percent / 100, self::ITEM_TAX_AMOUNT_PRECISION);
|
||||||
$this->base_tax_amount = round($this->quantity * $this->price * $this->tax_percent / 100, self::ITEM_TAX_AMOUNT_PRECISION);
|
$this->base_tax_amount = round($this->quantity * $this->price * $this->tax_percent / 100, self::ITEM_TAX_AMOUNT_PRECISION);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function calcFixedDiscountAmounts(float $discount, float $baseDiscount, string $code, int $cartRuleId): void
|
public function calcFixedDiscountAmounts(float $discount, float $baseDiscount, string $code, int $cartRuleId): void
|
||||||
{
|
{
|
||||||
$this->discount_amount = $this->quantity * $discount;
|
$this->discount_amount = $this->quantity * $discount;
|
||||||
$this->base_discount_amount = $this->quantity * $baseDiscount;
|
$this->base_discount_amount = $this->quantity * $baseDiscount;
|
||||||
$this->coupon_code = $code;
|
$this->coupon_code = $code;
|
||||||
$this->applied_cart_rule_ids = (string) $cartRuleId;
|
$this->applied_cart_rule_ids = (string)$cartRuleId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function calcPercentageDiscountAmounts(float $discount, string $code, int $cartRuleId): void
|
public function calcPercentageDiscountAmounts(float $discount, string $code, int $cartRuleId): void
|
||||||
{
|
{
|
||||||
$this->discount_percent = $discount;
|
$this->discount_percent = $discount;
|
||||||
$this->discount_amount = round(($this->total + $this->tax_amount) * $this->discount_percent / 100, self::ITEM_DISCOUNT_AMOUNT_PRECISION);
|
$this->discount_amount = round(($this->total + $this->tax_amount) * $this->discount_percent / 100, self::ITEM_DISCOUNT_AMOUNT_PRECISION);
|
||||||
$this->base_discount_amount = round(($this->base_total + $this->base_tax_amount) * $this->discount_percent / 100, self::ITEM_DISCOUNT_AMOUNT_PRECISION);
|
$this->base_discount_amount = round(($this->base_total + $this->base_tax_amount) * $this->discount_percent / 100, self::ITEM_DISCOUNT_AMOUNT_PRECISION);
|
||||||
$this->coupon_code = $code;
|
$this->coupon_code = $code;
|
||||||
$this->applied_cart_rule_ids = (string) $cartRuleId;
|
$this->applied_cart_rule_ids = (string)$cartRuleId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function toArray(): array
|
public function toArray(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'cart_id' => $this->cart_id,
|
'cart_id' => $this->cart_id,
|
||||||
'product_id' => $this->product_id,
|
'product_id' => $this->product_id,
|
||||||
'quantity' => $this->quantity,
|
'quantity' => $this->quantity,
|
||||||
'price' => $this->price,
|
'price' => $this->price,
|
||||||
'base_price' => $this->base_price,
|
'base_price' => $this->base_price,
|
||||||
'total' => $this->total,
|
'total' => $this->total,
|
||||||
'base_total' => $this->base_total,
|
'base_total' => $this->base_total,
|
||||||
'tax_percent' => $this->tax_percent,
|
'tax_percent' => $this->tax_percent,
|
||||||
'tax_amount' => $this->tax_amount,
|
'tax_amount' => $this->tax_amount,
|
||||||
'base_tax_amount' => $this->base_tax_amount,
|
'base_tax_amount' => $this->base_tax_amount,
|
||||||
'coupon_code' => $this->coupon_code,
|
'coupon_code' => $this->coupon_code,
|
||||||
'discount_percent' => $this->discount_percent,
|
'discount_percent' => $this->discount_percent,
|
||||||
'discount_amount' => $this->discount_amount,
|
'discount_amount' => $this->discount_amount,
|
||||||
'base_discount_amount' => $this->base_discount_amount,
|
'base_discount_amount' => $this->base_discount_amount,
|
||||||
'applied_cart_rule_ids' => $this->applied_cart_rule_ids,
|
'applied_cart_rule_ids' => $this->applied_cart_rule_ids,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class expectedCart
|
class expectedCart
|
||||||
{
|
{
|
||||||
|
|
||||||
public const CART_TOTAL_PRECISION = 2;
|
public const CART_TOTAL_PRECISION = 2;
|
||||||
|
|
||||||
public $customer_id;
|
public $customer_id;
|
||||||
|
|
@ -168,39 +163,37 @@ class expectedCart
|
||||||
|
|
||||||
public function __construct(int $cartId, int $customerId)
|
public function __construct(int $cartId, int $customerId)
|
||||||
{
|
{
|
||||||
$this->id = $cartId;
|
$this->id = $cartId;
|
||||||
$this->customer_id = $customerId;
|
$this->customer_id = $customerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function applyCoupon(int $cartRuleId, string $couponCode): void
|
public function applyCoupon(int $cartRuleId, string $couponCode): void
|
||||||
{
|
{
|
||||||
$this->coupon_code = $couponCode;
|
$this->coupon_code = $couponCode;
|
||||||
$this->applied_cart_rule_ids = (string) $cartRuleId;
|
$this->applied_cart_rule_ids = (string)$cartRuleId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function finalizeTotals(): void
|
public function finalizeTotals(): void
|
||||||
{
|
{
|
||||||
$this->sub_total = round($this->sub_total, self::CART_TOTAL_PRECISION);
|
$this->sub_total = round($this->sub_total, self::CART_TOTAL_PRECISION);
|
||||||
$this->tax_total = round($this->tax_total, self::CART_TOTAL_PRECISION);
|
$this->tax_total = round($this->tax_total, self::CART_TOTAL_PRECISION);
|
||||||
$this->discount_amount = round($this->discount_amount, self::CART_TOTAL_PRECISION);
|
$this->discount_amount = round($this->discount_amount, self::CART_TOTAL_PRECISION);
|
||||||
$this->grand_total = round($this->sub_total + $this->tax_total - $this->discount_amount, self::CART_TOTAL_PRECISION);
|
$this->grand_total = round($this->sub_total + $this->tax_total - $this->discount_amount, self::CART_TOTAL_PRECISION);
|
||||||
|
|
||||||
$this->base_sub_total = round($this->base_sub_total, self::CART_TOTAL_PRECISION);
|
$this->base_sub_total = round($this->base_sub_total, self::CART_TOTAL_PRECISION);
|
||||||
$this->base_tax_total = round($this->base_tax_total, self::CART_TOTAL_PRECISION);
|
$this->base_tax_total = round($this->base_tax_total, self::CART_TOTAL_PRECISION);
|
||||||
$this->base_discount_amount = round($this->base_discount_amount, self::CART_TOTAL_PRECISION);
|
$this->base_discount_amount = round($this->base_discount_amount, self::CART_TOTAL_PRECISION);
|
||||||
$this->base_grand_total = round($this->base_sub_total + $this->base_tax_total - $this->base_discount_amount, self::CART_TOTAL_PRECISION);
|
$this->base_grand_total = round($this->base_sub_total + $this->base_tax_total - $this->base_discount_amount, self::CART_TOTAL_PRECISION);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function toArray(): array
|
public function toArray(): array
|
||||||
{
|
{
|
||||||
return (array) $this;
|
return (array)$this;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class expectedOrder implements Arrayable
|
class expectedOrder implements Arrayable
|
||||||
{
|
{
|
||||||
|
|
||||||
public $status;
|
public $status;
|
||||||
|
|
||||||
public $customer_email;
|
public $customer_email;
|
||||||
|
|
@ -247,63 +240,61 @@ class expectedOrder implements Arrayable
|
||||||
|
|
||||||
public function __construct(expectedCart $expectedCart, Customer $customer, int $cartId)
|
public function __construct(expectedCart $expectedCart, Customer $customer, int $cartId)
|
||||||
{
|
{
|
||||||
$this->status = 'pending';
|
$this->status = 'pending';
|
||||||
$this->customer_email = $customer->email;
|
$this->customer_email = $customer->email;
|
||||||
$this->customer_first_name = $customer->first_name;
|
$this->customer_first_name = $customer->first_name;
|
||||||
$this->customer_vat_id = $customer->vat_id;
|
$this->customer_vat_id = $customer->vat_id;
|
||||||
$this->coupon_code = $expectedCart->coupon_code;
|
$this->coupon_code = $expectedCart->coupon_code;
|
||||||
$this->total_item_count = $expectedCart->items_count;
|
$this->total_item_count = $expectedCart->items_count;
|
||||||
$this->total_qty_ordered = $expectedCart->items_qty;
|
$this->total_qty_ordered = $expectedCart->items_qty;
|
||||||
$this->grand_total = $expectedCart->grand_total;
|
$this->grand_total = $expectedCart->grand_total;
|
||||||
$this->base_grand_total = $expectedCart->base_grand_total;
|
$this->base_grand_total = $expectedCart->base_grand_total;
|
||||||
$this->sub_total = $expectedCart->sub_total;
|
$this->sub_total = $expectedCart->sub_total;
|
||||||
$this->base_sub_total = $expectedCart->base_sub_total;
|
$this->base_sub_total = $expectedCart->base_sub_total;
|
||||||
$this->discount_amount = $expectedCart->discount_amount;
|
$this->discount_amount = $expectedCart->discount_amount;
|
||||||
$this->base_discount_amount = $expectedCart->base_discount_amount;
|
$this->base_discount_amount = $expectedCart->base_discount_amount;
|
||||||
$this->tax_amount = $expectedCart->tax_total;
|
$this->tax_amount = $expectedCart->tax_total;
|
||||||
$this->base_tax_amount = $expectedCart->base_tax_total;
|
$this->base_tax_amount = $expectedCart->base_tax_total;
|
||||||
$this->customer_id = $customer->id;
|
$this->customer_id = $customer->id;
|
||||||
$this->cart_id = $cartId;
|
$this->cart_id = $cartId;
|
||||||
$this->applied_cart_rule_ids = $expectedCart->applied_cart_rule_ids;
|
$this->applied_cart_rule_ids = $expectedCart->applied_cart_rule_ids;
|
||||||
$this->shipping_method = null;
|
$this->shipping_method = null;
|
||||||
$this->shipping_amount = null;
|
$this->shipping_amount = null;
|
||||||
$this->base_shipping_amount = null;
|
$this->base_shipping_amount = null;
|
||||||
$this->shipping_discount_amount = null;
|
$this->shipping_discount_amount = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function toArray(): array
|
public function toArray(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'status' => $this->status,
|
'status' => $this->status,
|
||||||
'customer_email' => $this->customer_email,
|
'customer_email' => $this->customer_email,
|
||||||
'customer_first_name' => $this->customer_first_name,
|
'customer_first_name' => $this->customer_first_name,
|
||||||
'customer_vat_id' => $this->customer_vat_id,
|
'customer_vat_id' => $this->customer_vat_id,
|
||||||
'coupon_code' => $this->coupon_code,
|
'coupon_code' => $this->coupon_code,
|
||||||
'total_item_count' => $this->total_item_count,
|
'total_item_count' => $this->total_item_count,
|
||||||
'total_qty_ordered' => $this->total_qty_ordered,
|
'total_qty_ordered' => $this->total_qty_ordered,
|
||||||
'grand_total' => $this->grand_total,
|
'grand_total' => $this->grand_total,
|
||||||
'base_grand_total' => $this->base_grand_total,
|
'base_grand_total' => $this->base_grand_total,
|
||||||
'sub_total' => $this->sub_total,
|
'sub_total' => $this->sub_total,
|
||||||
'base_sub_total' => $this->base_sub_total,
|
'base_sub_total' => $this->base_sub_total,
|
||||||
'discount_amount' => $this->discount_amount,
|
'discount_amount' => $this->discount_amount,
|
||||||
'base_discount_amount' => $this->base_discount_amount,
|
'base_discount_amount' => $this->base_discount_amount,
|
||||||
'tax_amount' => $this->tax_amount,
|
'tax_amount' => $this->tax_amount,
|
||||||
'base_tax_amount' => $this->base_tax_amount,
|
'base_tax_amount' => $this->base_tax_amount,
|
||||||
'customer_id' => $this->customer_id,
|
'customer_id' => $this->customer_id,
|
||||||
'cart_id' => $this->cart_id,
|
'cart_id' => $this->cart_id,
|
||||||
'applied_cart_rule_ids' => $this->applied_cart_rule_ids,
|
'applied_cart_rule_ids' => $this->applied_cart_rule_ids,
|
||||||
'shipping_method' => $this->shipping_method,
|
'shipping_method' => $this->shipping_method,
|
||||||
'shipping_amount' => $this->shipping_amount,
|
'shipping_amount' => $this->shipping_amount,
|
||||||
'base_shipping_amount' => $this->base_shipping_amount,
|
'base_shipping_amount' => $this->base_shipping_amount,
|
||||||
'shipping_discount_amount' => $this->shipping_discount_amount,
|
'shipping_discount_amount' => $this->shipping_discount_amount,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class CartRuleCest
|
class CartRuleCest
|
||||||
{
|
{
|
||||||
|
|
||||||
private $products;
|
private $products;
|
||||||
|
|
||||||
private $sessionToken;
|
private $sessionToken;
|
||||||
|
|
@ -371,51 +362,51 @@ class CartRuleCest
|
||||||
// ],
|
// ],
|
||||||
// ohne coupon
|
// ohne coupon
|
||||||
[
|
[
|
||||||
'name' => 'PRODUCT_FREE no coupon',
|
'name' => 'PRODUCT_FREE no coupon',
|
||||||
'productSequence' => [
|
'productSequence' => [
|
||||||
self::PRODUCT_FREE,
|
self::PRODUCT_FREE,
|
||||||
],
|
],
|
||||||
'withCoupon' => false,
|
'withCoupon' => false,
|
||||||
'checkOrder' => false,
|
'checkOrder' => false,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => 'PRODUCT_NOT_FREE no coupon',
|
'name' => 'PRODUCT_NOT_FREE no coupon',
|
||||||
'productSequence' => [
|
'productSequence' => [
|
||||||
self::PRODUCT_NOT_FREE,
|
self::PRODUCT_NOT_FREE,
|
||||||
],
|
],
|
||||||
'withCoupon' => false,
|
'withCoupon' => false,
|
||||||
'checkOrder' => false,
|
'checkOrder' => false,
|
||||||
],
|
],
|
||||||
// fixer Coupon für ein Produkt (Warenkorb wird nicht 0)
|
// fixer Coupon für ein Produkt (Warenkorb wird nicht 0)
|
||||||
[
|
[
|
||||||
'name' => 'PRODUCT_NOT_FREE fix coupon',
|
'name' => 'PRODUCT_NOT_FREE fix coupon',
|
||||||
'productSequence' => [
|
'productSequence' => [
|
||||||
self::PRODUCT_NOT_FREE,
|
self::PRODUCT_NOT_FREE,
|
||||||
],
|
],
|
||||||
'withCoupon' => true,
|
'withCoupon' => true,
|
||||||
'couponScenario' => [
|
'couponScenario' => [
|
||||||
'scenario' => self::COUPON_FIXED,
|
'scenario' => self::COUPON_FIXED,
|
||||||
'products' => [
|
'products' => [
|
||||||
self::PRODUCT_NOT_FREE,
|
self::PRODUCT_NOT_FREE,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'checkOrder' => false,
|
'checkOrder' => false,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => 'check fix coupon on product with quantity=2',
|
'name' => 'check fix coupon on product with quantity=2',
|
||||||
'productSequence' => [
|
'productSequence' => [
|
||||||
self::PRODUCT_NOT_FREE,
|
self::PRODUCT_NOT_FREE,
|
||||||
self::PRODUCT_NOT_FREE_REDUCED_TAX,
|
self::PRODUCT_NOT_FREE_REDUCED_TAX,
|
||||||
self::PRODUCT_NOT_FREE,
|
self::PRODUCT_NOT_FREE,
|
||||||
],
|
],
|
||||||
'withCoupon' => true,
|
'withCoupon' => true,
|
||||||
'couponScenario' => [
|
'couponScenario' => [
|
||||||
'scenario' => self::COUPON_FIXED,
|
'scenario' => self::COUPON_FIXED,
|
||||||
'products' => [
|
'products' => [
|
||||||
self::PRODUCT_NOT_FREE,
|
self::PRODUCT_NOT_FREE,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'checkOrder' => false,
|
'checkOrder' => false,
|
||||||
],
|
],
|
||||||
// [
|
// [
|
||||||
// 'name' => 'check fix coupon applied to two products',
|
// 'name' => 'check fix coupon applied to two products',
|
||||||
|
|
@ -436,34 +427,34 @@ class CartRuleCest
|
||||||
// ],
|
// ],
|
||||||
// prozenturaler Coupon für ein Produkt (Warenkorb wird nicht 0)
|
// prozenturaler Coupon für ein Produkt (Warenkorb wird nicht 0)
|
||||||
[
|
[
|
||||||
'name' => 'PRODUCT_NOT_FREE percentage coupon',
|
'name' => 'PRODUCT_NOT_FREE percentage coupon',
|
||||||
'productSequence' => [
|
'productSequence' => [
|
||||||
self::PRODUCT_NOT_FREE,
|
self::PRODUCT_NOT_FREE,
|
||||||
],
|
],
|
||||||
'withCoupon' => true,
|
'withCoupon' => true,
|
||||||
'couponScenario' => [
|
'couponScenario' => [
|
||||||
'scenario' => self::COUPON_PERCENTAGE,
|
'scenario' => self::COUPON_PERCENTAGE,
|
||||||
'products' => [
|
'products' => [
|
||||||
self::PRODUCT_NOT_FREE,
|
self::PRODUCT_NOT_FREE,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'checkOrder' => false,
|
'checkOrder' => false,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => 'check percentage coupon on product with quantity=2',
|
'name' => 'check percentage coupon on product with quantity=2',
|
||||||
'productSequence' => [
|
'productSequence' => [
|
||||||
self::PRODUCT_NOT_FREE,
|
self::PRODUCT_NOT_FREE,
|
||||||
self::PRODUCT_NOT_FREE_REDUCED_TAX,
|
self::PRODUCT_NOT_FREE_REDUCED_TAX,
|
||||||
self::PRODUCT_NOT_FREE,
|
self::PRODUCT_NOT_FREE,
|
||||||
],
|
],
|
||||||
'withCoupon' => true,
|
'withCoupon' => true,
|
||||||
'couponScenario' => [
|
'couponScenario' => [
|
||||||
'scenario' => self::COUPON_PERCENTAGE,
|
'scenario' => self::COUPON_PERCENTAGE,
|
||||||
'products' => [
|
'products' => [
|
||||||
self::PRODUCT_NOT_FREE,
|
self::PRODUCT_NOT_FREE,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'checkOrder' => false,
|
'checkOrder' => false,
|
||||||
],
|
],
|
||||||
// [
|
// [
|
||||||
// 'name' => 'check percentage coupon applied to two products',
|
// 'name' => 'check percentage coupon applied to two products',
|
||||||
|
|
@ -484,34 +475,34 @@ class CartRuleCest
|
||||||
// ],
|
// ],
|
||||||
// fixer Coupon für ein Produkt (Warenkorb wird 0)
|
// fixer Coupon für ein Produkt (Warenkorb wird 0)
|
||||||
[
|
[
|
||||||
'name' => 'PRODUCT_NON_SUB_NOT_FREE fix coupon to zero',
|
'name' => 'PRODUCT_NON_SUB_NOT_FREE fix coupon to zero',
|
||||||
'productSequence' => [
|
'productSequence' => [
|
||||||
self::PRODUCT_NOT_FREE,
|
self::PRODUCT_NOT_FREE,
|
||||||
],
|
],
|
||||||
'withCoupon' => true,
|
'withCoupon' => true,
|
||||||
'couponScenario' => [
|
'couponScenario' => [
|
||||||
'scenario' => self::COUPON_FIXED_FULL,
|
'scenario' => self::COUPON_FIXED_FULL,
|
||||||
'products' => [
|
'products' => [
|
||||||
self::PRODUCT_NOT_FREE,
|
self::PRODUCT_NOT_FREE,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'checkOrder' => false,
|
'checkOrder' => false,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => 'check fix coupon to zero on product with quantity=2',
|
'name' => 'check fix coupon to zero on product with quantity=2',
|
||||||
'productSequence' => [
|
'productSequence' => [
|
||||||
self::PRODUCT_NOT_FREE,
|
self::PRODUCT_NOT_FREE,
|
||||||
self::PRODUCT_NOT_FREE_REDUCED_TAX,
|
self::PRODUCT_NOT_FREE_REDUCED_TAX,
|
||||||
self::PRODUCT_NOT_FREE,
|
self::PRODUCT_NOT_FREE,
|
||||||
],
|
],
|
||||||
'withCoupon' => true,
|
'withCoupon' => true,
|
||||||
'couponScenario' => [
|
'couponScenario' => [
|
||||||
'scenario' => self::COUPON_FIXED_FULL,
|
'scenario' => self::COUPON_FIXED_FULL,
|
||||||
'products' => [
|
'products' => [
|
||||||
self::PRODUCT_NOT_FREE,
|
self::PRODUCT_NOT_FREE,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'checkOrder' => false,
|
'checkOrder' => false,
|
||||||
],
|
],
|
||||||
// [
|
// [
|
||||||
// 'name' => 'check fix coupon to zero applied to two products',
|
// 'name' => 'check fix coupon to zero applied to two products',
|
||||||
|
|
@ -532,34 +523,34 @@ class CartRuleCest
|
||||||
// ],
|
// ],
|
||||||
// prozenturaler Coupon für ein Produkt (Warenkorb wird 0)
|
// prozenturaler Coupon für ein Produkt (Warenkorb wird 0)
|
||||||
[
|
[
|
||||||
'name' => 'PRODUCT_NOT_FREE percentage coupon to zero',
|
'name' => 'PRODUCT_NOT_FREE percentage coupon to zero',
|
||||||
'productSequence' => [
|
'productSequence' => [
|
||||||
self::PRODUCT_NOT_FREE,
|
self::PRODUCT_NOT_FREE,
|
||||||
],
|
],
|
||||||
'withCoupon' => true,
|
'withCoupon' => true,
|
||||||
'couponScenario' => [
|
'couponScenario' => [
|
||||||
'scenario' => self::COUPON_PERCENTAGE_FULL,
|
'scenario' => self::COUPON_PERCENTAGE_FULL,
|
||||||
'products' => [
|
'products' => [
|
||||||
self::PRODUCT_NOT_FREE,
|
self::PRODUCT_NOT_FREE,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'checkOrder' => false,
|
'checkOrder' => false,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => 'check percentage coupon to zero on product with quantity=2',
|
'name' => 'check percentage coupon to zero on product with quantity=2',
|
||||||
'productSequence' => [
|
'productSequence' => [
|
||||||
self::PRODUCT_NOT_FREE,
|
self::PRODUCT_NOT_FREE,
|
||||||
self::PRODUCT_NOT_FREE_REDUCED_TAX,
|
self::PRODUCT_NOT_FREE_REDUCED_TAX,
|
||||||
self::PRODUCT_NOT_FREE,
|
self::PRODUCT_NOT_FREE,
|
||||||
],
|
],
|
||||||
'withCoupon' => true,
|
'withCoupon' => true,
|
||||||
'couponScenario' => [
|
'couponScenario' => [
|
||||||
'scenario' => self::COUPON_PERCENTAGE_FULL,
|
'scenario' => self::COUPON_PERCENTAGE_FULL,
|
||||||
'products' => [
|
'products' => [
|
||||||
self::PRODUCT_NOT_FREE,
|
self::PRODUCT_NOT_FREE,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'checkOrder' => false,
|
'checkOrder' => false,
|
||||||
],
|
],
|
||||||
// [
|
// [
|
||||||
// 'name' => 'check percentage coupon to zero applied to two products',
|
// 'name' => 'check percentage coupon to zero applied to two products',
|
||||||
|
|
@ -604,7 +595,7 @@ class CartRuleCest
|
||||||
$this->sessionToken = $faker->uuid;
|
$this->sessionToken = $faker->uuid;
|
||||||
session(['_token' => $this->sessionToken]);
|
session(['_token' => $this->sessionToken]);
|
||||||
|
|
||||||
$taxCategories = $this->generateTaxCategories($I);
|
$taxCategories = $this->generateTaxCategories($I);
|
||||||
$this->products = $this->generateProducts($I, $scenario['productSequence'], $taxCategories);
|
$this->products = $this->generateProducts($I, $scenario['productSequence'], $taxCategories);
|
||||||
|
|
||||||
$cartRuleWithCoupon = null;
|
$cartRuleWithCoupon = null;
|
||||||
|
|
@ -614,9 +605,9 @@ class CartRuleCest
|
||||||
|
|
||||||
foreach ($scenario['productSequence'] as $productIndex) {
|
foreach ($scenario['productSequence'] as $productIndex) {
|
||||||
$data = [
|
$data = [
|
||||||
'_token' => session('_token'),
|
'_token' => session('_token'),
|
||||||
'product_id' => $this->products[$productIndex]->id,
|
'product_id' => $this->products[$productIndex]->id,
|
||||||
'quantity' => 1,
|
'quantity' => 1,
|
||||||
];
|
];
|
||||||
|
|
||||||
cart()->addProduct($this->products[$productIndex]->id, $data);
|
cart()->addProduct($this->products[$productIndex]->id, $data);
|
||||||
|
|
@ -624,7 +615,7 @@ class CartRuleCest
|
||||||
|
|
||||||
if ($scenario['withCoupon']) {
|
if ($scenario['withCoupon']) {
|
||||||
$expectedCartCoupon = $cartRuleWithCoupon->coupon->code;
|
$expectedCartCoupon = $cartRuleWithCoupon->coupon->code;
|
||||||
$I->comment('I try to use coupon code '.$expectedCartCoupon);
|
$I->comment('I try to use coupon code ' . $expectedCartCoupon);
|
||||||
cart()
|
cart()
|
||||||
->setCouponCode($expectedCartCoupon)
|
->setCouponCode($expectedCartCoupon)
|
||||||
->collectTotals();
|
->collectTotals();
|
||||||
|
|
@ -655,43 +646,43 @@ class CartRuleCest
|
||||||
|
|
||||||
$customerAddress = $I->have(CustomerAddress::class, [
|
$customerAddress = $I->have(CustomerAddress::class, [
|
||||||
'first_name' => $customer->first_name,
|
'first_name' => $customer->first_name,
|
||||||
'last_name' => $customer->last_name,
|
'last_name' => $customer->last_name,
|
||||||
'country' => 'DE',
|
'country' => 'DE',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$billing = [
|
$billing = [
|
||||||
'address1' => $customerAddress->address1,
|
'address1' => $customerAddress->address1,
|
||||||
'use_for_shipping' => true,
|
'use_for_shipping' => true,
|
||||||
'first_name' => $customerAddress->first_name,
|
'first_name' => $customerAddress->first_name,
|
||||||
'last_name' => $customerAddress->last_name,
|
'last_name' => $customerAddress->last_name,
|
||||||
'email' => $customer->email,
|
'email' => $customer->email,
|
||||||
'company_name' => $customerAddress->company_name,
|
'company_name' => $customerAddress->company_name,
|
||||||
'city' => $customerAddress->city,
|
'city' => $customerAddress->city,
|
||||||
'postcode' => $customerAddress->postcode,
|
'postcode' => $customerAddress->postcode,
|
||||||
'country' => $customerAddress->country,
|
'country' => $customerAddress->country,
|
||||||
'state' => $customerAddress->state,
|
'state' => $customerAddress->state,
|
||||||
'phone' => $customerAddress->phone,
|
'phone' => $customerAddress->phone,
|
||||||
];
|
];
|
||||||
|
|
||||||
$shipping = [
|
$shipping = [
|
||||||
'address1' => '',
|
'address1' => '',
|
||||||
'first_name' => $customerAddress->first_name,
|
'first_name' => $customerAddress->first_name,
|
||||||
'last_name' => $customerAddress->last_name,
|
'last_name' => $customerAddress->last_name,
|
||||||
'email' => $customer->email,
|
'email' => $customer->email,
|
||||||
];
|
];
|
||||||
|
|
||||||
cart()->saveCustomerAddress([
|
cart()->saveCustomerAddress([
|
||||||
'billing' => $billing,
|
'billing' => $billing,
|
||||||
'shipping' => $shipping,
|
'shipping' => $shipping,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
cart()->saveShippingMethod('free_free');
|
cart()->saveShippingMethod('free_free');
|
||||||
cart()->savePaymentMethod(['method' => 'mollie_creditcard']);
|
cart()->savePaymentMethod(['method' => 'mollie_creditcard']);
|
||||||
$I->assertFalse(cart()->hasError());
|
$I->assertFalse(cart()->hasError());
|
||||||
$orderItemRepository = new OrderItemRepository(app());
|
$orderItemRepository = new OrderItemRepository(app());
|
||||||
$downloadableLinkRepository = new ProductDownloadableLinkRepository(app());
|
$downloadableLinkRepository = new ProductDownloadableLinkRepository(app());
|
||||||
$downloadableLinkPurchasedRepository = new DownloadableLinkPurchasedRepository($downloadableLinkRepository, app());
|
$downloadableLinkPurchasedRepository = new DownloadableLinkPurchasedRepository($downloadableLinkRepository, app());
|
||||||
$orderRepository = new OrderRepository($orderItemRepository, $downloadableLinkPurchasedRepository, app());
|
$orderRepository = new OrderRepository($orderItemRepository, $downloadableLinkPurchasedRepository, app());
|
||||||
|
|
||||||
$orderRepository->create(cart()->prepareDataForOrder());
|
$orderRepository->create(cart()->prepareDataForOrder());
|
||||||
$expectedOrder = new expectedOrder($expectedCart, $customer, $cart->id);
|
$expectedOrder = new expectedOrder($expectedCart, $customer, $cart->id);
|
||||||
|
|
@ -720,76 +711,76 @@ class CartRuleCest
|
||||||
session(['_token' => $this->sessionToken]);
|
session(['_token' => $this->sessionToken]);
|
||||||
|
|
||||||
$tax = $I->have(TaxRate::class, [
|
$tax = $I->have(TaxRate::class, [
|
||||||
'country' => 'DE',
|
'country' => 'DE',
|
||||||
'tax_rate' => 19.0,
|
'tax_rate' => 19.0,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$taxCategorie = $I->have(TaxCategory::class);
|
$taxCategorie = $I->have(TaxCategory::class);
|
||||||
|
|
||||||
$I->have(TaxMap::class, [
|
$I->have(TaxMap::class, [
|
||||||
'tax_rate_id' => $tax->id,
|
'tax_rate_id' => $tax->id,
|
||||||
'tax_category_id' => $taxCategorie->id,
|
'tax_category_id' => $taxCategorie->id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$productConfig = [
|
$productConfig = [
|
||||||
'attributeValues' => [
|
'attributeValues' => [
|
||||||
'price' => 23.92,
|
'price' => 23.92,
|
||||||
'tax_category_id' => $taxCategorie->id,
|
'tax_category_id' => $taxCategorie->id,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
$product = $I->haveProduct(Laravel5Helper::SIMPLE_PRODUCT, $productConfig);
|
$product = $I->haveProduct(Laravel5Helper::SIMPLE_PRODUCT, $productConfig);
|
||||||
|
|
||||||
$ruleConfig = [
|
$ruleConfig = [
|
||||||
'action_type' => self::ACTION_TYPE_PERCENTAGE,
|
'action_type' => self::ACTION_TYPE_PERCENTAGE,
|
||||||
'discount_amount' => 100,
|
'discount_amount' => 100,
|
||||||
'conditions' => [
|
'conditions' => [
|
||||||
[
|
[
|
||||||
'attribute' => 'product|sku',
|
'attribute' => 'product|sku',
|
||||||
'value' => $product->sku,
|
'value' => $product->sku,
|
||||||
'operator' => '==',
|
'operator' => '==',
|
||||||
'attribute_type' => 'text',
|
'attribute_type' => 'text',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
$cartRule = $I->have(CartRule::class, $ruleConfig);
|
$cartRule = $I->have(CartRule::class, $ruleConfig);
|
||||||
|
|
||||||
DB::table('cart_rule_channels')
|
DB::table('cart_rule_channels')
|
||||||
->insert([
|
->insert([
|
||||||
'cart_rule_id' => $cartRule->id,
|
'cart_rule_id' => $cartRule->id,
|
||||||
'channel_id' => core()->getCurrentChannel()->id,
|
'channel_id' => core()->getCurrentChannel()->id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$guestCustomerGroup = $I->grabRecord('customer_groups', ['code' => 'guest']);
|
$guestCustomerGroup = $I->grabRecord('customer_groups', ['code' => 'guest']);
|
||||||
DB::table('cart_rule_customer_groups')
|
DB::table('cart_rule_customer_groups')
|
||||||
->insert([
|
->insert([
|
||||||
'cart_rule_id' => $cartRule->id,
|
'cart_rule_id' => $cartRule->id,
|
||||||
'customer_group_id' => $guestCustomerGroup['id'],
|
'customer_group_id' => $guestCustomerGroup['id'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$generalCustomerGroup = $I->grabRecord('customer_groups', ['code' => 'general']);
|
$generalCustomerGroup = $I->grabRecord('customer_groups', ['code' => 'general']);
|
||||||
DB::table('cart_rule_customer_groups')
|
DB::table('cart_rule_customer_groups')
|
||||||
->insert([
|
->insert([
|
||||||
'cart_rule_id' => $cartRule->id,
|
'cart_rule_id' => $cartRule->id,
|
||||||
'customer_group_id' => $generalCustomerGroup['id'],
|
'customer_group_id' => $generalCustomerGroup['id'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$coupon = $I->have(CartRuleCoupon::class, [
|
$coupon = $I->have(CartRuleCoupon::class, [
|
||||||
'code' => 'AWESOME',
|
'code' => 'AWESOME',
|
||||||
'cart_rule_id' => $cartRule->id,
|
'cart_rule_id' => $cartRule->id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'_token' => session('_token'),
|
'_token' => session('_token'),
|
||||||
'product_id' => $product->id,
|
'product_id' => $product->id,
|
||||||
'quantity' => 1,
|
'quantity' => 1,
|
||||||
];
|
];
|
||||||
cart()->addProduct($product->id, $data);
|
cart()->addProduct($product->id, $data);
|
||||||
cart()
|
cart()
|
||||||
->setCouponCode('AWESOME')
|
->setCouponCode('AWESOME')
|
||||||
->collectTotals();
|
->collectTotals();
|
||||||
|
|
||||||
$cart = cart()->getCart();
|
$cart = cart()->getCart();
|
||||||
$cartItem = $cart->items()
|
$cartItem = $cart->items()
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
|
|
@ -834,8 +825,8 @@ class CartRuleCest
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case self::PRODUCT_NOT_FREE:
|
case self::PRODUCT_NOT_FREE:
|
||||||
$cartItem->price = self::PRODUCT_PRICE;
|
$cartItem->price = self::PRODUCT_PRICE;
|
||||||
$cartItem->base_price = self::PRODUCT_PRICE;
|
$cartItem->base_price = self::PRODUCT_PRICE;
|
||||||
$cartItem->tax_percent = self::TAX_RATE;
|
$cartItem->tax_percent = self::TAX_RATE;
|
||||||
|
|
||||||
$cartItem->calcTotals();
|
$cartItem->calcTotals();
|
||||||
|
|
@ -843,8 +834,8 @@ class CartRuleCest
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case self::PRODUCT_NOT_FREE_REDUCED_TAX:
|
case self::PRODUCT_NOT_FREE_REDUCED_TAX:
|
||||||
$cartItem->price = self::REDUCED_PRODUCT_PRICE;
|
$cartItem->price = self::REDUCED_PRODUCT_PRICE;
|
||||||
$cartItem->base_price = self::REDUCED_PRODUCT_PRICE;
|
$cartItem->base_price = self::REDUCED_PRODUCT_PRICE;
|
||||||
$cartItem->tax_percent = self::REDUCED_TAX_RATE;
|
$cartItem->tax_percent = self::REDUCED_TAX_RATE;
|
||||||
|
|
||||||
$cartItem->calcTotals();
|
$cartItem->calcTotals();
|
||||||
|
|
@ -900,7 +891,7 @@ class CartRuleCest
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($scenario['withCoupon'] && $scenario['couponScenario']['scenario'] === self::COUPON_FIXED_CART) {
|
if ($scenario['withCoupon'] && $scenario['couponScenario']['scenario'] === self::COUPON_FIXED_CART) {
|
||||||
$totals = $this->calcTotals($cartItems);
|
$totals = $this->calcTotals($cartItems);
|
||||||
$cartItems = $this->splitDiscountToItems($cartItems, $cartRuleWithCoupon, $totals);
|
$cartItems = $this->splitDiscountToItems($cartItems, $cartRuleWithCoupon, $totals);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -910,14 +901,14 @@ class CartRuleCest
|
||||||
private function calcTotals(array $cartItems): array
|
private function calcTotals(array $cartItems): array
|
||||||
{
|
{
|
||||||
$result = [
|
$result = [
|
||||||
'subTotal' => 0.0,
|
'subTotal' => 0.0,
|
||||||
'baseSubTotal' => 0.0,
|
'baseSubTotal' => 0.0,
|
||||||
];
|
];
|
||||||
foreach ($cartItems as $expectedCartItem) {
|
foreach ($cartItems as $expectedCartItem) {
|
||||||
$result['subTotal'] += $expectedCartItem->total;
|
$result['subTotal'] += $expectedCartItem->total;
|
||||||
$result['baseSubTotal'] += $expectedCartItem->base_total;
|
$result['baseSubTotal'] += $expectedCartItem->base_total;
|
||||||
}
|
}
|
||||||
$result['subTotal'] = round($result['subTotal'], expectedCart::CART_TOTAL_PRECISION);
|
$result['subTotal'] = round($result['subTotal'], expectedCart::CART_TOTAL_PRECISION);
|
||||||
$result['baseSubTotal'] = round($result['baseSubTotal'], expectedCart::CART_TOTAL_PRECISION);
|
$result['baseSubTotal'] = round($result['baseSubTotal'], expectedCart::CART_TOTAL_PRECISION);
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
|
|
@ -928,26 +919,26 @@ class CartRuleCest
|
||||||
cartRuleWithCoupon $cartRuleWithCoupon,
|
cartRuleWithCoupon $cartRuleWithCoupon,
|
||||||
array $totals
|
array $totals
|
||||||
): array {
|
): array {
|
||||||
$discountAmount = self::DISCOUNT_AMOUNT_CART;
|
$discountAmount = self::DISCOUNT_AMOUNT_CART;
|
||||||
$baseDiscountAmount = self::DISCOUNT_AMOUNT_CART;
|
$baseDiscountAmount = self::DISCOUNT_AMOUNT_CART;
|
||||||
// split coupon amount to cart items
|
// split coupon amount to cart items
|
||||||
$length = count($cartItems) - 1;
|
$length = count($cartItems) - 1;
|
||||||
for ($i = 0; $i < $length; $i++) {
|
for ($i = 0; $i < $length; $i++) {
|
||||||
$cartItems[$i]->discount_amount = round(self::DISCOUNT_AMOUNT_CART * $cartItems[$i]->total / $totals['subTotal'], expectedCartItem::ITEM_DISCOUNT_AMOUNT_PRECISION);
|
$cartItems[$i]->discount_amount = round(self::DISCOUNT_AMOUNT_CART * $cartItems[$i]->total / $totals['subTotal'], expectedCartItem::ITEM_DISCOUNT_AMOUNT_PRECISION);
|
||||||
$discountAmount -= $cartItems[$i]->discount_amount;
|
$discountAmount -= $cartItems[$i]->discount_amount;
|
||||||
|
|
||||||
$cartItems[$i]->base_discount_amount = round(self::DISCOUNT_AMOUNT_CART * $cartItems[$i]->base_total / $totals['baseSubTotal'], expectedCartItem::ITEM_DISCOUNT_AMOUNT_PRECISION);
|
$cartItems[$i]->base_discount_amount = round(self::DISCOUNT_AMOUNT_CART * $cartItems[$i]->base_total / $totals['baseSubTotal'], expectedCartItem::ITEM_DISCOUNT_AMOUNT_PRECISION);
|
||||||
$baseDiscountAmount -= $cartItems[$i]->discount_amount;
|
$baseDiscountAmount -= $cartItems[$i]->discount_amount;
|
||||||
|
|
||||||
$cartItems[$i]->coupon_code = $cartRuleWithCoupon->coupon->code;
|
$cartItems[$i]->coupon_code = $cartRuleWithCoupon->coupon->code;
|
||||||
$cartItems[$i]->applied_cart_rule_ids = (string) $cartRuleWithCoupon->cartRule->id;
|
$cartItems[$i]->applied_cart_rule_ids = (string)$cartRuleWithCoupon->cartRule->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
$cartItems[$length]->discount_amount = $discountAmount;
|
$cartItems[$length]->discount_amount = $discountAmount;
|
||||||
$cartItems[$length]->base_discount_amount = $baseDiscountAmount;
|
$cartItems[$length]->base_discount_amount = $baseDiscountAmount;
|
||||||
|
|
||||||
$cartItems[$length]->coupon_code = $cartRuleWithCoupon->coupon->code;
|
$cartItems[$length]->coupon_code = $cartRuleWithCoupon->coupon->code;
|
||||||
$cartItems[$length]->applied_cart_rule_ids = (string) $cartRuleWithCoupon->cartRule->id;
|
$cartItems[$length]->applied_cart_rule_ids = (string)$cartRuleWithCoupon->cartRule->id;
|
||||||
|
|
||||||
return $cartItems;
|
return $cartItems;
|
||||||
}
|
}
|
||||||
|
|
@ -996,12 +987,12 @@ class CartRuleCest
|
||||||
$cart->items_count++;
|
$cart->items_count++;
|
||||||
$cart->items_qty += $cartItem->quantity;
|
$cart->items_qty += $cartItem->quantity;
|
||||||
|
|
||||||
$cart->sub_total += $cartItem->total;
|
$cart->sub_total += $cartItem->total;
|
||||||
$cart->tax_total += $cartItem->tax_amount;
|
$cart->tax_total += $cartItem->tax_amount;
|
||||||
$cart->discount_amount += $cartItem->discount_amount;
|
$cart->discount_amount += $cartItem->discount_amount;
|
||||||
|
|
||||||
$cart->base_sub_total += $cartItem->base_total;
|
$cart->base_sub_total += $cartItem->base_total;
|
||||||
$cart->base_tax_total += $cartItem->base_tax_amount;
|
$cart->base_tax_total += $cartItem->base_tax_amount;
|
||||||
$cart->base_discount_amount += $cartItem->base_discount_amount;
|
$cart->base_discount_amount += $cartItem->base_discount_amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1017,18 +1008,18 @@ class CartRuleCest
|
||||||
*/
|
*/
|
||||||
private function generateTaxCategories(UnitTester $I): array
|
private function generateTaxCategories(UnitTester $I): array
|
||||||
{
|
{
|
||||||
$result = [];
|
$result = [];
|
||||||
$country = strtoupper(Config::get('app.default_country')) ?? 'DE';
|
$country = strtoupper(Config::get('app.default_country')) ?? 'DE';
|
||||||
foreach ($this->getTaxRateSpecifications() as $taxSpec => $taxRate) {
|
foreach ($this->getTaxRateSpecifications() as $taxSpec => $taxRate) {
|
||||||
$tax = $I->have(TaxRate::class, [
|
$tax = $I->have(TaxRate::class, [
|
||||||
'country' => $country,
|
'country' => $country,
|
||||||
'tax_rate' => $taxRate,
|
'tax_rate' => $taxRate,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$taxCategorie = $I->have(TaxCategory::class);
|
$taxCategorie = $I->have(TaxCategory::class);
|
||||||
|
|
||||||
$I->have(TaxMap::class, [
|
$I->have(TaxMap::class, [
|
||||||
'tax_rate_id' => $tax->id,
|
'tax_rate_id' => $tax->id,
|
||||||
'tax_category_id' => $taxCategorie->id,
|
'tax_category_id' => $taxCategorie->id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
@ -1048,11 +1039,11 @@ class CartRuleCest
|
||||||
*/
|
*/
|
||||||
private function generateProducts(UnitTester $I, array $scenario, array $taxCategories): array
|
private function generateProducts(UnitTester $I, array $scenario, array $taxCategories): array
|
||||||
{
|
{
|
||||||
$products = [];
|
$products = [];
|
||||||
$productSpecs = $this->getProductSpecifications();
|
$productSpecs = $this->getProductSpecifications();
|
||||||
|
|
||||||
foreach ($scenario as $item) {
|
foreach ($scenario as $item) {
|
||||||
$productConfig = $this->makeProductConfig($productSpecs[$item], $taxCategories);
|
$productConfig = $this->makeProductConfig($productSpecs[$item], $taxCategories);
|
||||||
$products[$item] = $I->haveProduct($productSpecs[$item]['productType'], $productConfig);
|
$products[$item] = $I->haveProduct($productSpecs[$item]['productType'], $productConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1070,26 +1061,26 @@ class CartRuleCest
|
||||||
$faker = Factory::create();
|
$faker = Factory::create();
|
||||||
|
|
||||||
$couponSpecifications = $this->getCouponSpecifications();
|
$couponSpecifications = $this->getCouponSpecifications();
|
||||||
$ruleConfig = $this->makeRuleConfig($couponSpecifications[$couponConfig['scenario']], $this->products, $couponConfig['products']);
|
$ruleConfig = $this->makeRuleConfig($couponSpecifications[$couponConfig['scenario']], $this->products, $couponConfig['products']);
|
||||||
$cartRule = $I->have(CartRule::class, $ruleConfig);
|
$cartRule = $I->have(CartRule::class, $ruleConfig);
|
||||||
|
|
||||||
DB::table('cart_rule_channels')
|
DB::table('cart_rule_channels')
|
||||||
->insert([
|
->insert([
|
||||||
'cart_rule_id' => $cartRule->id,
|
'cart_rule_id' => $cartRule->id,
|
||||||
'channel_id' => core()->getCurrentChannel()->id,
|
'channel_id' => core()->getCurrentChannel()->id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$guestCustomerGroup = $I->grabRecord('customer_groups', ['code' => 'guest']);
|
$guestCustomerGroup = $I->grabRecord('customer_groups', ['code' => 'guest']);
|
||||||
DB::table('cart_rule_customer_groups')
|
DB::table('cart_rule_customer_groups')
|
||||||
->insert([
|
->insert([
|
||||||
'cart_rule_id' => $cartRule->id,
|
'cart_rule_id' => $cartRule->id,
|
||||||
'customer_group_id' => $guestCustomerGroup['id'],
|
'customer_group_id' => $guestCustomerGroup['id'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$generalCustomerGroup = $I->grabRecord('customer_groups', ['code' => 'general']);
|
$generalCustomerGroup = $I->grabRecord('customer_groups', ['code' => 'general']);
|
||||||
DB::table('cart_rule_customer_groups')
|
DB::table('cart_rule_customer_groups')
|
||||||
->insert([
|
->insert([
|
||||||
'cart_rule_id' => $cartRule->id,
|
'cart_rule_id' => $cartRule->id,
|
||||||
'customer_group_id' => $generalCustomerGroup['id'],
|
'customer_group_id' => $generalCustomerGroup['id'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
@ -1112,8 +1103,8 @@ class CartRuleCest
|
||||||
'productInventory' => [
|
'productInventory' => [
|
||||||
'qty' => 100,
|
'qty' => 100,
|
||||||
],
|
],
|
||||||
'attributeValues' => [
|
'attributeValues' => [
|
||||||
'price' => 0.0,
|
'price' => 0.0,
|
||||||
'tax_category_id' => $taxCategories[self::TAX_CATEGORY],
|
'tax_category_id' => $taxCategories[self::TAX_CATEGORY],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
@ -1146,17 +1137,17 @@ class CartRuleCest
|
||||||
{
|
{
|
||||||
foreach ($couponableProducts as $item) {
|
foreach ($couponableProducts as $item) {
|
||||||
$conditions[] = [
|
$conditions[] = [
|
||||||
'value' => $products[$item]->sku,
|
'value' => $products[$item]->sku,
|
||||||
'operator' => '==',
|
'operator' => '==',
|
||||||
'attribute' => 'product|sku',
|
'attribute' => 'product|sku',
|
||||||
'attribute_type' => 'text',
|
'attribute_type' => 'text',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = [
|
$result = [
|
||||||
'action_type' => $ruleSpec['actionType'],
|
'action_type' => $ruleSpec['actionType'],
|
||||||
'discount_amount' => $ruleSpec['discountAmount'],
|
'discount_amount' => $ruleSpec['discountAmount'],
|
||||||
'conditions' => $conditions ?? null,
|
'conditions' => $conditions ?? null,
|
||||||
];
|
];
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
|
|
@ -1170,21 +1161,21 @@ class CartRuleCest
|
||||||
return [
|
return [
|
||||||
[
|
[
|
||||||
'productScenario' => self::PRODUCT_FREE,
|
'productScenario' => self::PRODUCT_FREE,
|
||||||
'productType' => Laravel5Helper::SIMPLE_PRODUCT,
|
'productType' => Laravel5Helper::SIMPLE_PRODUCT,
|
||||||
'freeOfCharge' => true,
|
'freeOfCharge' => true,
|
||||||
'reducedTax' => false,
|
'reducedTax' => false,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'productScenario' => self::PRODUCT_NOT_FREE,
|
'productScenario' => self::PRODUCT_NOT_FREE,
|
||||||
'productType' => Laravel5Helper::SIMPLE_PRODUCT,
|
'productType' => Laravel5Helper::SIMPLE_PRODUCT,
|
||||||
'freeOfCharge' => false,
|
'freeOfCharge' => false,
|
||||||
'reducedTax' => false,
|
'reducedTax' => false,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'productScenario' => self::PRODUCT_NOT_FREE_REDUCED_TAX,
|
'productScenario' => self::PRODUCT_NOT_FREE_REDUCED_TAX,
|
||||||
'productType' => Laravel5Helper::SIMPLE_PRODUCT,
|
'productType' => Laravel5Helper::SIMPLE_PRODUCT,
|
||||||
'freeOfCharge' => false,
|
'freeOfCharge' => false,
|
||||||
'reducedTax' => true,
|
'reducedTax' => true,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
@ -1197,27 +1188,27 @@ class CartRuleCest
|
||||||
return [
|
return [
|
||||||
[
|
[
|
||||||
'couponScenario' => self::COUPON_FIXED,
|
'couponScenario' => self::COUPON_FIXED,
|
||||||
'actionType' => self::ACTION_TYPE_FIXED,
|
'actionType' => self::ACTION_TYPE_FIXED,
|
||||||
'discountAmount' => self::DISCOUNT_AMOUNT_FIX,
|
'discountAmount' => self::DISCOUNT_AMOUNT_FIX,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'couponScenario' => self::COUPON_FIXED_FULL,
|
'couponScenario' => self::COUPON_FIXED_FULL,
|
||||||
'actionType' => self::ACTION_TYPE_FIXED,
|
'actionType' => self::ACTION_TYPE_FIXED,
|
||||||
'discountAmount' => self::DISCOUNT_AMOUNT_FIX_FULL,
|
'discountAmount' => self::DISCOUNT_AMOUNT_FIX_FULL,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'couponScenario' => self::COUPON_PERCENTAGE,
|
'couponScenario' => self::COUPON_PERCENTAGE,
|
||||||
'actionType' => self::ACTION_TYPE_PERCENTAGE,
|
'actionType' => self::ACTION_TYPE_PERCENTAGE,
|
||||||
'discountAmount' => self::DISCOUNT_AMOUNT_PERCENT,
|
'discountAmount' => self::DISCOUNT_AMOUNT_PERCENT,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'couponScenario' => self::COUPON_PERCENTAGE_FULL,
|
'couponScenario' => self::COUPON_PERCENTAGE_FULL,
|
||||||
'actionType' => self::ACTION_TYPE_PERCENTAGE,
|
'actionType' => self::ACTION_TYPE_PERCENTAGE,
|
||||||
'discountAmount' => 100.0,
|
'discountAmount' => 100.0,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'couponScenario' => self::COUPON_FIXED_CART,
|
'couponScenario' => self::COUPON_FIXED_CART,
|
||||||
'actionType' => self::ACTION_TYPE_CART_FIXED,
|
'actionType' => self::ACTION_TYPE_CART_FIXED,
|
||||||
'discountAmount' => self::DISCOUNT_AMOUNT_CART,
|
'discountAmount' => self::DISCOUNT_AMOUNT_CART,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
@ -1229,7 +1220,7 @@ class CartRuleCest
|
||||||
private function getTaxRateSpecifications(): array
|
private function getTaxRateSpecifications(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
self::TAX_CATEGORY => self::TAX_RATE,
|
self::TAX_CATEGORY => self::TAX_RATE,
|
||||||
self::TAX_REDUCED_CATEGORY => self::REDUCED_TAX_RATE,
|
self::TAX_REDUCED_CATEGORY => self::REDUCED_TAX_RATE,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
@ -1251,6 +1242,4 @@ class CartRuleCest
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue