PR 1782 Enhancement: Let variants be of other types than simple
This commit is contained in:
parent
58bad6fbed
commit
71e8e687c2
|
|
@ -64,7 +64,7 @@
|
|||
</select>
|
||||
|
||||
@if ($familyId)
|
||||
<input type="hidden" name="type" value="configurable"/>
|
||||
<input type="hidden" name="type" value="{{ app('request')->input('type') }}"/>
|
||||
@endif
|
||||
<span class="control-error" v-if="errors.has('type')">@{{ errors.first('type') }}</span>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Customer\Http\Listeners;
|
||||
use Cookie;
|
||||
use Cart;
|
||||
|
||||
class CustomerEventsHandler {
|
||||
|
||||
/**
|
||||
* Handle Customer login events.
|
||||
*/
|
||||
public function onCustomerLogin($event)
|
||||
{
|
||||
/**
|
||||
* handle the user login event to manage the after login, if the user has added any products as guest then
|
||||
* the cart items from session will be transferred from cookie to the cart table in the database.
|
||||
*
|
||||
* Check whether cookie is present or not and then check emptiness and then do the appropriate actions.
|
||||
*/
|
||||
Cart::mergeCart();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the listeners for the subscriber.
|
||||
*
|
||||
* @param Illuminate\Events\Dispatcher $events
|
||||
* @return void
|
||||
*/
|
||||
public function subscribe($events)
|
||||
{
|
||||
$events->listen('customer.after.login', 'Webkul\Customer\Http\Listeners\CustomerEventsHandler@onCustomerLogin');
|
||||
}
|
||||
}
|
||||
|
|
@ -143,9 +143,16 @@ class Configurable extends AbstractType
|
|||
];
|
||||
}
|
||||
|
||||
$typeOfVariants = 'simple';
|
||||
$productInstance = app(config('product_types.' . $product->type . '.class'));
|
||||
if ($productInstance->variantsType && !in_array($productInstance->variantsType , ['bundle', 'configurable', 'grouped']))
|
||||
{
|
||||
$typeOfVariants = $productInstance->variantsType;
|
||||
}
|
||||
|
||||
$variant = $this->productRepository->getModel()->create([
|
||||
'parent_id' => $product->id,
|
||||
'type' => 'simple',
|
||||
'type' => $typeOfVariants,
|
||||
'attribute_family_id' => $product->attribute_family_id,
|
||||
'sku' => $data['sku'],
|
||||
]);
|
||||
|
|
|
|||
Loading…
Reference in New Issue