diff --git a/packages/Webkul/Product/src/Type/AbstractType.php b/packages/Webkul/Product/src/Type/AbstractType.php
index 8f22a0838..f0d6e76d7 100644
--- a/packages/Webkul/Product/src/Type/AbstractType.php
+++ b/packages/Webkul/Product/src/Type/AbstractType.php
@@ -1053,7 +1053,7 @@ abstract class AbstractType
/**
* Get offers lines.
*
- * @param array $customerGroupPrice
+ * @param object $customerGroupPrice
* @return array
*/
public function getOfferLines($customerGroupPrice)
diff --git a/packages/Webkul/Product/src/Type/Bundle.php b/packages/Webkul/Product/src/Type/Bundle.php
index 3038530dc..6cf5bf106 100644
--- a/packages/Webkul/Product/src/Type/Bundle.php
+++ b/packages/Webkul/Product/src/Type/Bundle.php
@@ -17,63 +17,65 @@ use Webkul\Product\Repositories\ProductVideoRepository;
class Bundle extends AbstractType
{
/**
- * ProductBundleOptionRepository instance
+ * Product bundle option repository instance.
*
* @var \Webkul\Product\Repositories\ProductBundleOptionRepository
*/
protected $productBundleOptionRepository;
/**
- * ProductBundleOptionProductRepository instance
+ * Product bundle option product repository instance.
*
* @var \Webkul\Product\Repositories\ProductBundleOptionProductRepository
*/
protected $productBundleOptionProductRepository;
/**
- * Bundle Option helper instance
+ * Bundle Option helper instance.
*
* @var \Webkul\Product\Helpers\BundleOption
- */
+ */
protected $bundleOptionHelper;
/**
- * Skip attribute for Bundle product type
+ * Skip attribute for Bundle product type.
*
* @var array
*/
protected $skipAttributes = ['price', 'cost', 'special_price', 'special_price_from', 'special_price_to', 'length', 'width', 'height', 'weight'];
/**
- * These blade files will be included in product edit page
+ * These blade files will be included in product edit page.
*
* @var array
*/
protected $additionalViews = [
'admin::catalog.products.accordians.images',
+ 'admin::catalog.products.accordians.videos',
'admin::catalog.products.accordians.categories',
'admin::catalog.products.accordians.bundle-items',
'admin::catalog.products.accordians.channels',
'admin::catalog.products.accordians.product-links',
- 'admin::catalog.products.accordians.videos',
];
/**
- * Is a composite product type
+ * Is a composite product type.
*
* @var bool
*/
protected $isComposite = true;
/**
- * Product children price can be calculated or not
+ * Product children price can be calculated or not.
*
* @var bool
*/
protected $isChildrenCalculated = true;
/**
- * Product Options
+ * Product options.
+ *
+ * @var array
*/
protected $productOptions = [];
@@ -101,8 +103,7 @@ class Bundle extends AbstractType
ProductBundleOptionProductRepository $productBundleOptionProductRepository,
BundleOption $bundleOptionHelper,
ProductVideoRepository $productVideoRepository
- )
- {
+ ) {
parent::__construct(
$attributeRepository,
$productRepository,
@@ -120,12 +121,14 @@ class Bundle extends AbstractType
}
/**
+ * Update.
+ *
* @param array $data
* @param int $id
* @param string $attribute
* @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);
$route = request()->route() ? request()->route()->getName() : '';
@@ -138,7 +141,7 @@ class Bundle extends AbstractType
}
/**
- * Returns children ids
+ * Returns children ids.
*
* @return array
*/
@@ -148,7 +151,7 @@ class Bundle extends AbstractType
}
/**
- * Check if catalog rule can be applied
+ * Check if catalog rule can be applied.
*
* @return bool
*/
@@ -158,7 +161,7 @@ class Bundle extends AbstractType
}
/**
- * Get product minimal price
+ * Get product minimal price.
*
* @param int $qty
* @return float
@@ -193,7 +196,7 @@ class Bundle extends AbstractType
}
/**
- * Get product regular minimal price
+ * Get product regular minimal price.
*
* @return float
*/
@@ -227,7 +230,7 @@ class Bundle extends AbstractType
}
/**
- * Get product regular minimal price
+ * Get product regular minimal price.
*
* @param \Webkul\Product\Contracts\ProductBundleOption $option
* @param bool $minPrice
@@ -243,17 +246,17 @@ class Bundle extends AbstractType
}
$optionPrices[] = $bundleOptionProduct->qty
- * ($minPrice
- ? $bundleOptionProduct->product->getTypeInstance()->getMinimalPrice()
- : $bundleOptionProduct->product->price
- );
+ * ($minPrice
+ ? $bundleOptionProduct->product->getTypeInstance()->getMinimalPrice()
+ : $bundleOptionProduct->product->price
+ );
}
return $optionPrices;
}
/**
- * Check if product has required options or not
+ * Check if product has required options or not.
*
* @return bool
*/
@@ -269,7 +272,7 @@ class Bundle extends AbstractType
}
/**
- * Get product maximam price
+ * Get product maximum price.
*
* @return float
*/
@@ -306,7 +309,7 @@ class Bundle extends AbstractType
}
/**
- * Get product regular maximam price
+ * Get product regular maximum price.
*
* @return float
*/
@@ -343,7 +346,7 @@ class Bundle extends AbstractType
}
/**
- * Get product minimal price
+ * Get product minimal price.
*
* @param int $qty
* @return float
@@ -354,7 +357,7 @@ class Bundle extends AbstractType
}
/**
- * Returns product prices
+ * Returns product prices.
*
* @return array
*/
@@ -369,10 +372,10 @@ class Bundle extends AbstractType
'final_price' => [
'price' => core()->convertPrice($this->evaluatePrice($this->getMinimalPrice())),
'formated_price' => core()->currency($this->evaluatePrice($this->getMinimalPrice())),
- ]
+ ],
],
- 'to' => [
+ 'to' => [
'regular_price' => [
'price' => core()->convertPrice($this->evaluatePrice($this->getRegularMaximamPrice())),
'formated_price' => core()->currency($this->evaluatePrice($this->getRegularMaximamPrice())),
@@ -380,13 +383,13 @@ class Bundle extends AbstractType
'final_price' => [
'price' => core()->convertPrice($this->evaluatePrice($this->getMaximamPrice())),
'formated_price' => core()->currency($this->evaluatePrice($this->getMaximamPrice())),
- ]
- ]
+ ],
+ ],
];
}
/**
- * Get bundle product special price
+ * Get bundle product special price.
*
* @return boolean
*/
@@ -405,7 +408,7 @@ class Bundle extends AbstractType
}
/**
- * Get product minimal price
+ * Get product minimal price.
*
* @return string
*/
@@ -415,19 +418,19 @@ class Bundle extends AbstractType
$priceHtml = '';
- if ($this->checkBundleProductHaveSpecialPrice())
+ if ($this->checkBundleProductHaveSpecialPrice()) {
$priceHtml .= '
' . trans('shop::app.products.sale') . '
';
+ }
$priceHtml .= '';
if ($prices['from']['regular_price']['price'] != $prices['from']['final_price']['price']) {
$priceHtml .= '' . $prices['from']['regular_price']['formated_price'] . ''
- . '' . $prices['from']['final_price']['formated_price'] . '';
+ . '' . $prices['from']['final_price']['formated_price'] . '';
} else {
$priceHtml .= '' . $prices['from']['regular_price']['formated_price'] . '';
}
-
if ($prices['from']['regular_price']['price'] != $prices['to']['regular_price']['price']
|| $prices['from']['final_price']['price'] != $prices['to']['final_price']['price']
) {
@@ -435,7 +438,7 @@ class Bundle extends AbstractType
if ($prices['to']['regular_price']['price'] != $prices['to']['final_price']['price']) {
$priceHtml .= '' . $prices['to']['regular_price']['formated_price'] . ''
- . '' . $prices['to']['final_price']['formated_price'] . '';
+ . '' . $prices['to']['final_price']['formated_price'] . '';
} else {
$priceHtml .= '' . $prices['to']['regular_price']['formated_price'] . '';
}
@@ -552,6 +555,7 @@ class Bundle extends AbstractType
}
/**
+ * Compare options.
*
* @param array $options1
* @param array $options2
@@ -564,17 +568,20 @@ class Bundle extends AbstractType
}
if (isset($options1['bundle_options']) && isset($options2['bundle_options'])) {
- return $options1['bundle_options'] == $options2['bundle_options']
- && $options1['bundle_option_qty'] == $this->getOptionQuantities($options2);
- } elseif (! isset($options1['bundle_options'])) {
+ return $options1['bundle_options'] == $options2['bundle_options'] && $options1['bundle_option_qty'] == $this->getOptionQuantities($options2);
+ }
+
+ if (! isset($options1['bundle_options'])) {
return false;
- } elseif (! isset($options2['bundle_options'])) {
+ }
+
+ if (! isset($options2['bundle_options'])) {
return false;
}
}
/**
- * Remove invalid options from add to cart request
+ * Remove invalid options from add to cart request.
*
* @param array $data
* @return array
@@ -585,7 +592,7 @@ class Bundle extends AbstractType
if (is_array($value)) {
$data[$key] = $this->validateBundleOptionForCart($value);
} elseif ($value && $value) {
- $data[$key] = (int)$value;
+ $data[$key] = (int) $value;
} else {
unset($data[$key]);
}
@@ -595,7 +602,7 @@ class Bundle extends AbstractType
}
/**
- * Returns additional information for items
+ * Returns additional information for items.
*
* @param array $data
* @return array
@@ -628,7 +635,7 @@ class Bundle extends AbstractType
$label = $qty . ' x ' . $optionProduct->product->name;
$price = $optionProduct->product->getTypeInstance()->getMinimalPrice();
- if($price != 0){
+ if ($price != 0) {
$label .= ' ' . core()->currency($price);
}
@@ -650,7 +657,7 @@ class Bundle extends AbstractType
}
/**
- * Returns additional information for items
+ * Returns additional information for items.
*
* @param array $data
* @return array
@@ -681,10 +688,9 @@ class Bundle extends AbstractType
}
/**
- * Validate cart item product price and other things
- *
- * @param \Webkul\Checkout\Models\CartItem $item
+ * Validate cart item product price and other things.
*
+ * @param \Webkul\Checkout\Models\CartItem $item
* @return \Webkul\Product\Datatypes\CartItemValidationResult
*/
public function validateCartItem(CartItem $item): CartItemValidationResult
@@ -732,17 +738,23 @@ class Bundle extends AbstractType
}
/**
- * get product options
+ * Get product options.
+ *
+ * @param object $product
+ * @return mixed
*/
- public function getProductOptions($product = "")
+ public function getProductOptions($product = '')
{
$bundleOption = app('Webkul\Product\Helpers\BundleOption');
+
$options = $bundleOption->getProductOptions($product);
return $options;
}
/**
+ * Have sufficient quantity.
+ *
* @param int $qty
* @return bool
*/
diff --git a/packages/Webkul/Product/src/Type/Configurable.php b/packages/Webkul/Product/src/Type/Configurable.php
index 278b83d77..a61ccb8e5 100644
--- a/packages/Webkul/Product/src/Type/Configurable.php
+++ b/packages/Webkul/Product/src/Type/Configurable.php
@@ -33,11 +33,11 @@ class Configurable extends AbstractType
*/
protected $additionalViews = [
'admin::catalog.products.accordians.images',
+ 'admin::catalog.products.accordians.videos',
'admin::catalog.products.accordians.categories',
'admin::catalog.products.accordians.variations',
'admin::catalog.products.accordians.channels',
'admin::catalog.products.accordians.product-links',
- 'admin::catalog.products.accordians.videos',
];
/**
@@ -347,7 +347,7 @@ class Configurable extends AbstractType
* Fill required fields.
*
* @param array $data
- * @param int $id
+ * @param int $id
* @return \Webkul\Product\Contracts\Product
*/
public function fillRequiredFields(array $data): array
@@ -365,7 +365,7 @@ class Configurable extends AbstractType
/**
* Check variant option availability.
*
- * @param array $data
+ * @param array $data
* @param \Webkul\Product\Contracts\Product $product
* @return bool
*/
@@ -653,9 +653,13 @@ class Configurable extends AbstractType
if (isset($options1['selected_configurable_option']) && isset($options2['selected_configurable_option'])) {
return $options1['selected_configurable_option'] === $options2['selected_configurable_option'];
- } elseif (! isset($options1['selected_configurable_option'])) {
+ }
+
+ if (! isset($options1['selected_configurable_option'])) {
return false;
- } elseif (! isset($options2['selected_configurable_option'])) {
+ }
+
+ if (! isset($options2['selected_configurable_option'])) {
return false;
}
}
diff --git a/packages/Webkul/Product/src/Type/Downloadable.php b/packages/Webkul/Product/src/Type/Downloadable.php
index c6311ce80..dcc7a3232 100644
--- a/packages/Webkul/Product/src/Type/Downloadable.php
+++ b/packages/Webkul/Product/src/Type/Downloadable.php
@@ -16,56 +16,58 @@ use Webkul\Product\Repositories\ProductVideoRepository;
class Downloadable extends AbstractType
{
/**
- * ProductDownloadableLinkRepository instance
+ * Product downloadable link repository instance.
*
* @var \Webkul\Product\Repositories\ProductDownloadableLinkRepository
*/
protected $productDownloadableLinkRepository;
/**
- * ProductDownloadableSampleRepository instance
+ * Product downloadable sample repository instance.
*
* @var \Webkul\Product\Repositories\ProductDownloadableSampleRepository
*/
protected $productDownloadableSampleRepository;
/**
- * Skip attribute for downloadable product type
+ * Skip attribute for downloadable product type.
*
* @var array
*/
protected $skipAttributes = ['length', 'width', 'height', 'weight', 'guest_checkout'];
/**
- * These blade files will be included in product edit page
+ * These blade files will be included in product edit page.
*
* @var array
*/
protected $additionalViews = [
'admin::catalog.products.accordians.images',
+ 'admin::catalog.products.accordians.videos',
'admin::catalog.products.accordians.categories',
'admin::catalog.products.accordians.downloadable',
'admin::catalog.products.accordians.channels',
'admin::catalog.products.accordians.product-links',
- 'admin::catalog.products.accordians.videos',
];
/**
- * Is a stokable product type
+ * Is a stokable product type.
*
* @var bool
*/
protected $isStockable = false;
/**
- * Show quantity box
+ * Show quantity box.
*
* @var bool
*/
protected $allowMultipleQty = false;
/**
- * getProductOptions
+ * Get product options.
+ *
+ * @var array
*/
protected $getProductOptions = [];
@@ -80,7 +82,6 @@ class Downloadable extends AbstractType
* @param \Webkul\Product\Repositories\ProductDownloadableLinkRepository $productDownloadableLinkRepository
* @param \Webkul\Product\Repositories\ProductDownloadableSampleRepository $productDownloadableSampleRepository
* @param \Webkul\Product\Repositories\ProductVideoRepository $productVideoRepository
- *
* @return void
*/
public function __construct(
@@ -92,8 +93,7 @@ class Downloadable extends AbstractType
ProductDownloadableLinkRepository $productDownloadableLinkRepository,
ProductDownloadableSampleRepository $productDownloadableSampleRepository,
ProductVideoRepository $productVideoRepository
- )
- {
+ ) {
parent::__construct(
$attributeRepository,
$productRepository,
@@ -109,13 +109,14 @@ class Downloadable extends AbstractType
}
/**
- * @param array $data
- * @param int $id
- * @param string $attribute
+ * Update.
*
+ * @param array $data
+ * @param int $id
+ * @param string $attribute
* @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);
$route = request()->route() ? request()->route()->getName() : '';
@@ -130,7 +131,7 @@ class Downloadable extends AbstractType
}
/**
- * Return true if this product type is saleable
+ * Return true if this product type is saleable.
*
* @return bool
*/
@@ -153,14 +154,13 @@ class Downloadable extends AbstractType
}
/**
- * Returns validation rules
+ * Returns validation rules.
*
* @return array
*/
public function getTypeValidationRules()
{
return [
- // 'downloadable_links.*.title' => 'required',
'downloadable_links.*.type' => 'required',
'downloadable_links.*.file' => 'required_if:type,==,file',
'downloadable_links.*.file_name' => 'required_if:type,==,file',
@@ -173,8 +173,7 @@ class Downloadable extends AbstractType
/**
* Add product. Returns error message if can't prepare product.
*
- * @param array $data
- *
+ * @param array $data
* @return array
*/
public function prepareForCart($data)
@@ -200,10 +199,10 @@ class Downloadable extends AbstractType
}
/**
+ * Compare options.
*
- * @param array $options1
- * @param array $options2
- *
+ * @param array $options1
+ * @param array $options2
* @return bool
*/
public function compareOptions($options1, $options2)
@@ -214,18 +213,21 @@ class Downloadable extends AbstractType
if (isset($options1['links']) && isset($options2['links'])) {
return $options1['links'] === $options2['links'];
- } elseif (! isset($options1['links'])) {
+ }
+
+ if (! isset($options1['links'])) {
return false;
- } elseif (! isset($options2['links'])) {
+ }
+
+ if (! isset($options2['links'])) {
return false;
}
}
/**
- * Returns additional information for items
- *
- * @param array $data
+ * Returns additional information for items.
*
+ * @param array $data
* @return array
*/
public function getAdditionalOptions($data)
@@ -250,8 +252,7 @@ class Downloadable extends AbstractType
/**
* Validate cart item product price
*
- * @param \Webkul\Checkout\Models\CartItem $item
- *
+ * @param \Webkul\Checkout\Models\CartItem $item
* @return \Webkul\Product\Datatypes\CartItemValidationResult
*/
public function validateCartItem(CartItem $item): CartItemValidationResult
@@ -292,7 +293,7 @@ class Downloadable extends AbstractType
}
/**
- * Get product maximam price
+ * Get product maximum price
*
* @return float
*/
diff --git a/packages/Webkul/Product/src/Type/Grouped.php b/packages/Webkul/Product/src/Type/Grouped.php
index fcb84e5b1..4687464d0 100644
--- a/packages/Webkul/Product/src/Type/Grouped.php
+++ b/packages/Webkul/Product/src/Type/Grouped.php
@@ -34,11 +34,11 @@ class Grouped extends AbstractType
*/
protected $additionalViews = [
'admin::catalog.products.accordians.images',
+ 'admin::catalog.products.accordians.videos',
'admin::catalog.products.accordians.categories',
'admin::catalog.products.accordians.grouped-products',
'admin::catalog.products.accordians.channels',
'admin::catalog.products.accordians.product-links',
- 'admin::catalog.products.accordians.videos',
];
/**
diff --git a/packages/Webkul/Product/src/Type/Simple.php b/packages/Webkul/Product/src/Type/Simple.php
index 100b2a228..679640bae 100644
--- a/packages/Webkul/Product/src/Type/Simple.php
+++ b/packages/Webkul/Product/src/Type/Simple.php
@@ -5,17 +5,17 @@ namespace Webkul\Product\Type;
class Simple extends AbstractType
{
/**
- * These blade files will be included in product edit page
+ * These blade files will be included in product edit page.
*
* @var array
*/
protected $additionalViews = [
'admin::catalog.products.accordians.inventories',
'admin::catalog.products.accordians.images',
+ 'admin::catalog.products.accordians.videos',
'admin::catalog.products.accordians.categories',
'admin::catalog.products.accordians.channels',
'admin::catalog.products.accordians.product-links',
- 'admin::catalog.products.accordians.videos',
];
/**
@@ -52,6 +52,8 @@ class Simple extends AbstractType
}
/**
+ * Have sufficient quantity.
+ *
* @param int $qty
* @return bool
*/
@@ -59,13 +61,13 @@ class Simple extends AbstractType
{
$backorders = core()->getConfigData('catalog.inventory.stock_options.backorders');
- $backorders = ! is_null ($backorders) ? $backorders : false;
+ $backorders = ! is_null($backorders) ? $backorders : false;
return $qty <= $this->totalQuantity() ? true : $backorders;
}
/**
- * Get product maximam price
+ * Get product maximum price.
*
* @return float
*/
diff --git a/packages/Webkul/Product/src/Type/Virtual.php b/packages/Webkul/Product/src/Type/Virtual.php
index bff7eb883..eacb5a021 100644
--- a/packages/Webkul/Product/src/Type/Virtual.php
+++ b/packages/Webkul/Product/src/Type/Virtual.php
@@ -5,42 +5,42 @@ namespace Webkul\Product\Type;
class Virtual extends AbstractType
{
/**
- * Skip attribute for virtual product type
+ * Skip attribute for virtual product type.
*
* @var array
*/
protected $skipAttributes = ['length', 'width', 'height', 'weight'];
/**
- * These blade files will be included in product edit page
+ * These blade files will be included in product edit page.
*
* @var array
*/
protected $additionalViews = [
'admin::catalog.products.accordians.inventories',
'admin::catalog.products.accordians.images',
+ 'admin::catalog.products.accordians.videos',
'admin::catalog.products.accordians.categories',
'admin::catalog.products.accordians.channels',
'admin::catalog.products.accordians.product-links',
- 'admin::catalog.products.accordians.videos',
];
/**
- * Is a stokable product type
+ * Is a stokable product type.
*
* @var bool
*/
protected $isStockable = false;
/**
- * Show quantity box
+ * Show quantity box.
*
* @var bool
*/
protected $showQuantityBox = true;
/**
- * Return true if this product type is saleable
+ * Return true if this product type is saleable.
*
* @return bool
*/
@@ -63,8 +63,9 @@ class Virtual extends AbstractType
}
/**
- * @param int $qty
+ * Have sufficient quantity.
*
+ * @param int $qty
* @return bool
*/
public function haveSufficientQuantity(int $qty): bool
@@ -73,7 +74,7 @@ class Virtual extends AbstractType
}
/**
- * Get product maximam price
+ * Get product maximum price.
*
* @return float
*/