Merge pull request #5454 from devansh-webkul/conf-issue
Quantity Added #5451
This commit is contained in:
commit
837f78fa28
|
|
@ -95,7 +95,7 @@ class Configurable extends AbstractType
|
||||||
public function setDefaultVariantId($defaultVariantId)
|
public function setDefaultVariantId($defaultVariantId)
|
||||||
{
|
{
|
||||||
$this->product->additional = array_merge($this->product->additional ?? [], [
|
$this->product->additional = array_merge($this->product->additional ?? [], [
|
||||||
'default_variant_id' => $defaultVariantId
|
'default_variant_id' => $defaultVariantId,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -152,7 +152,7 @@ class Configurable extends AbstractType
|
||||||
* @param string $attribute
|
* @param string $attribute
|
||||||
* @return \Webkul\Product\Contracts\Product
|
* @return \Webkul\Product\Contracts\Product
|
||||||
*/
|
*/
|
||||||
public function update(array $data, $id, $attribute = "id")
|
public function update(array $data, $id, $attribute = 'id')
|
||||||
{
|
{
|
||||||
$product = parent::update($data, $id, $attribute);
|
$product = parent::update($data, $id, $attribute);
|
||||||
|
|
||||||
|
|
@ -222,7 +222,7 @@ class Configurable extends AbstractType
|
||||||
$typeOfVariants = 'simple';
|
$typeOfVariants = 'simple';
|
||||||
$productInstance = app(config('product_types.' . $product->type . '.class'));
|
$productInstance = app(config('product_types.' . $product->type . '.class'));
|
||||||
|
|
||||||
if (isset($productInstance->variantsType) && ! in_array($productInstance->variantsType , ['bundle', 'configurable', 'grouped'])) {
|
if (isset($productInstance->variantsType) && ! in_array($productInstance->variantsType, ['bundle', 'configurable', 'grouped'])) {
|
||||||
$typeOfVariants = $productInstance->variantsType;
|
$typeOfVariants = $productInstance->variantsType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -333,7 +333,7 @@ class Configurable extends AbstractType
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
$this->attributeValueRepository->update([
|
$this->attributeValueRepository->update([
|
||||||
ProductAttributeValue::$attributeTypeFields[$attribute->type] => $data[$attribute->code]
|
ProductAttributeValue::$attributeTypeFields[$attribute->type] => $data[$attribute->code],
|
||||||
], $attributeValue->id);
|
], $attributeValue->id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -358,7 +358,7 @@ class Configurable extends AbstractType
|
||||||
return array_merge($data, [
|
return array_merge($data, [
|
||||||
'url_key' => $data['sku'],
|
'url_key' => $data['sku'],
|
||||||
'short_description' => $data['sku'],
|
'short_description' => $data['sku'],
|
||||||
'description' => $data['sku']
|
'description' => $data['sku'],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -487,7 +487,8 @@ class Configurable extends AbstractType
|
||||||
*
|
*
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
public function getOfferPrice() {
|
public function getOfferPrice()
|
||||||
|
{
|
||||||
$rulePrices = $customerGroupPrices = [];
|
$rulePrices = $customerGroupPrices = [];
|
||||||
|
|
||||||
foreach ($this->product->variants as $variant) {
|
foreach ($this->product->variants as $variant) {
|
||||||
|
|
@ -512,7 +513,8 @@ class Configurable extends AbstractType
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function haveOffer() {
|
public function haveOffer()
|
||||||
|
{
|
||||||
$haveOffer = false;
|
$haveOffer = false;
|
||||||
|
|
||||||
$offerPrice = $this->getOfferPrice();
|
$offerPrice = $this->getOfferPrice();
|
||||||
|
|
@ -535,7 +537,7 @@ class Configurable extends AbstractType
|
||||||
$productFlat = ProductFlat::join('products', 'product_flat.product_id', '=', 'products.id')
|
$productFlat = ProductFlat::join('products', 'product_flat.product_id', '=', 'products.id')
|
||||||
->distinct()
|
->distinct()
|
||||||
->where('products.parent_id', $this->product->id)
|
->where('products.parent_id', $this->product->id)
|
||||||
->selectRaw('MAX('.DB::getTablePrefix().'product_flat.price) AS max_price')
|
->selectRaw('MAX(' . DB::getTablePrefix() . 'product_flat.price) AS max_price')
|
||||||
->where('product_flat.channel', core()->getCurrentChannelCode())
|
->where('product_flat.channel', core()->getCurrentChannelCode())
|
||||||
->where('product_flat.locale', app()->getLocale())
|
->where('product_flat.locale', app()->getLocale())
|
||||||
->first();
|
->first();
|
||||||
|
|
@ -558,7 +560,7 @@ class Configurable extends AbstractType
|
||||||
'price' => $this->haveOffer()
|
'price' => $this->haveOffer()
|
||||||
? $this->evaluatePrice($this->getOfferPrice())
|
? $this->evaluatePrice($this->getOfferPrice())
|
||||||
: $this->evaluatePrice($this->getMinimalPrice()),
|
: $this->evaluatePrice($this->getMinimalPrice()),
|
||||||
]
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -607,12 +609,13 @@ class Configurable extends AbstractType
|
||||||
|
|
||||||
$price = $childProduct->getTypeInstance()->getFinalPrice();
|
$price = $childProduct->getTypeInstance()->getFinalPrice();
|
||||||
|
|
||||||
$products = [
|
return [
|
||||||
[
|
[
|
||||||
'product_id' => $this->product->id,
|
'product_id' => $this->product->id,
|
||||||
'sku' => $this->product->sku,
|
'sku' => $this->product->sku,
|
||||||
'quantity' => $data['quantity'],
|
|
||||||
'name' => $this->product->name,
|
'name' => $this->product->name,
|
||||||
|
'type' => $this->product->type,
|
||||||
|
'quantity' => $data['quantity'],
|
||||||
'price' => $convertedPrice = core()->convertPrice($price),
|
'price' => $convertedPrice = core()->convertPrice($price),
|
||||||
'base_price' => $price,
|
'base_price' => $price,
|
||||||
'total' => $convertedPrice * $data['quantity'],
|
'total' => $convertedPrice * $data['quantity'],
|
||||||
|
|
@ -620,22 +623,20 @@ class Configurable extends AbstractType
|
||||||
'weight' => $childProduct->weight,
|
'weight' => $childProduct->weight,
|
||||||
'total_weight' => $childProduct->weight * $data['quantity'],
|
'total_weight' => $childProduct->weight * $data['quantity'],
|
||||||
'base_total_weight' => $childProduct->weight * $data['quantity'],
|
'base_total_weight' => $childProduct->weight * $data['quantity'],
|
||||||
'type' => $this->product->type,
|
|
||||||
'additional' => $this->getAdditionalOptions($data),
|
'additional' => $this->getAdditionalOptions($data),
|
||||||
], [
|
], [
|
||||||
'parent_id' => $this->product->id,
|
'parent_id' => $this->product->id,
|
||||||
'product_id' => (int) $data['selected_configurable_option'],
|
'product_id' => (int) $data['selected_configurable_option'],
|
||||||
'sku' => $childProduct->sku,
|
'sku' => $childProduct->sku,
|
||||||
'name' => $childProduct->name,
|
'name' => $childProduct->name,
|
||||||
'type' => 'simple',
|
'type' => $childProduct->type,
|
||||||
|
'quantity' => $data['quantity'],
|
||||||
'additional' => [
|
'additional' => [
|
||||||
'product_id' => (int) $data['selected_configurable_option'],
|
'product_id' => (int) $data['selected_configurable_option'],
|
||||||
'parent_id' => $this->product->id
|
'parent_id' => $this->product->id,
|
||||||
|
],
|
||||||
],
|
],
|
||||||
]
|
|
||||||
];
|
];
|
||||||
|
|
||||||
return $products;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -762,7 +763,7 @@ class Configurable extends AbstractType
|
||||||
* @param string $product
|
* @param string $product
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getProductOptions($product = "")
|
public function getProductOptions($product = '')
|
||||||
{
|
{
|
||||||
$configurableOption = app('Webkul\Product\Helpers\ConfigurableOption');
|
$configurableOption = app('Webkul\Product\Helpers\ConfigurableOption');
|
||||||
$options = $configurableOption->getConfigurationConfig($product);
|
$options = $configurableOption->getConfigurationConfig($product);
|
||||||
|
|
@ -780,7 +781,7 @@ class Configurable extends AbstractType
|
||||||
{
|
{
|
||||||
$backorders = core()->getConfigData('catalog.inventory.stock_options.backorders');
|
$backorders = core()->getConfigData('catalog.inventory.stock_options.backorders');
|
||||||
|
|
||||||
$backorders = ! is_null ($backorders) ? $backorders : false;
|
$backorders = ! is_null($backorders) ? $backorders : false;
|
||||||
|
|
||||||
foreach ($this->product->variants as $variant) {
|
foreach ($this->product->variants as $variant) {
|
||||||
if ($variant->haveSufficientQuantity($qty)) {
|
if ($variant->haveSufficientQuantity($qty)) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue