-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #251 from oc-shopaholic/develop
Release version 1.25.0
- Loading branch information
Showing
32 changed files
with
1,079 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php namespace Lovata\Shopaholic\Classes\Event\Measure; | ||
|
||
use Lovata\Toolbox\Classes\Event\ModelHandler; | ||
|
||
use Lovata\Shopaholic\Models\Measure; | ||
use Lovata\Shopaholic\Classes\Item\MeasureItem; | ||
|
||
/** | ||
* Class MeasureModelHandler | ||
* @package Lovata\Shopaholic\Classes\Event\Measure | ||
* @author Andrey Kharanenka, [email protected], LOVATA Group | ||
*/ | ||
class MeasureModelHandler extends ModelHandler | ||
{ | ||
/** @var Measure */ | ||
protected $obElement; | ||
|
||
/** | ||
* Get model class name | ||
* @return string | ||
*/ | ||
protected function getModelClass() | ||
{ | ||
return Measure::class; | ||
} | ||
|
||
/** | ||
* Get item class name | ||
* @return string | ||
*/ | ||
protected function getItemClass() | ||
{ | ||
return MeasureItem::class; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
<?php namespace Lovata\Shopaholic\Classes\Event\Offer; | ||
|
||
use Lang; | ||
use Lovata\Shopaholic\Models\Measure; | ||
use Lovata\Shopaholic\Models\Settings; | ||
use Lovata\Toolbox\Classes\Event\AbstractBackendFieldHandler; | ||
|
||
use Lovata\Shopaholic\Models\Offer; | ||
use Lovata\Shopaholic\Controllers\Offers; | ||
|
||
/** | ||
* Class ExtendOfferFieldsHandler | ||
* @package Lovata\Shopaholic\Classes\Event\Offer | ||
* @author Andrey Kharanenka, [email protected], LOVATA Group | ||
*/ | ||
class ExtendOfferFieldsHandler extends AbstractBackendFieldHandler | ||
{ | ||
protected $iPriority = 15000; | ||
|
||
/** | ||
* Extend form fields | ||
* @param \Backend\Widgets\Form $obWidget | ||
*/ | ||
protected function extendFields($obWidget) | ||
{ | ||
$arAdditionFields = [ | ||
'weight' => [ | ||
'label' => $this->getWeightFieldLabel(), | ||
'type' => 'number', | ||
'span' => 'left', | ||
'tab' => 'lovata.shopaholic::lang.tab.dimensions', | ||
], | ||
'height' => [ | ||
'label' => $this->getDimensionsFieldLabel('lovata.toolbox::lang.field.height'), | ||
'type' => 'number', | ||
'span' => 'left', | ||
'tab' => 'lovata.shopaholic::lang.tab.dimensions', | ||
], | ||
'length' => [ | ||
'label' => $this->getDimensionsFieldLabel('lovata.toolbox::lang.field.length'), | ||
'type' => 'number', | ||
'span' => 'left', | ||
'tab' => 'lovata.shopaholic::lang.tab.dimensions', | ||
], | ||
'width' => [ | ||
'label' => $this->getDimensionsFieldLabel('lovata.toolbox::lang.field.width'), | ||
'type' => 'number', | ||
'span' => 'left', | ||
'tab' => 'lovata.shopaholic::lang.tab.dimensions', | ||
], | ||
'quantity_in_unit' => [ | ||
'label' => 'lovata.shopaholic::lang.field.quantity_in_unit', | ||
'type' => 'number', | ||
'span' => 'left', | ||
'tab' => 'lovata.shopaholic::lang.tab.dimensions', | ||
], | ||
'measure_of_unit' => [ | ||
'label' => 'lovata.shopaholic::lang.field.measure_of_unit', | ||
'type' => 'relation', | ||
'span' => 'left', | ||
'emptyOption' => 'lovata.toolbox::lang.field.empty', | ||
'tab' => 'lovata.shopaholic::lang.tab.dimensions', | ||
], | ||
]; | ||
|
||
$obWidget->addTabFields($arAdditionFields); | ||
} | ||
|
||
/** | ||
* Get weight field label | ||
* @return string | ||
*/ | ||
protected function getWeightFieldLabel() | ||
{ | ||
$sLabel = Lang::get('lovata.toolbox::lang.field.weight'); | ||
$iMeasureID = Settings::getValue('weight_measure'); | ||
if (empty($iMeasureID)) { | ||
return $sLabel; | ||
} | ||
|
||
$obMeasure = Measure::find($iMeasureID); | ||
if (empty($obMeasure)) { | ||
return $sLabel; | ||
} | ||
|
||
$sLabel .= " ({$obMeasure->name})"; | ||
|
||
return $sLabel; | ||
} | ||
|
||
/** | ||
* Get dimensions field label | ||
* @param string $sLangPath | ||
* @return string | ||
*/ | ||
protected function getDimensionsFieldLabel($sLangPath) | ||
{ | ||
$sLabel = Lang::get($sLangPath); | ||
$iMeasureID = Settings::getValue('dimensions_measure'); | ||
if (empty($iMeasureID)) { | ||
return $sLabel; | ||
} | ||
|
||
$obMeasure = Measure::find($iMeasureID); | ||
if (empty($obMeasure)) { | ||
return $sLabel; | ||
} | ||
|
||
$sLabel .= " ({$obMeasure->name})"; | ||
|
||
return $sLabel; | ||
} | ||
|
||
/** | ||
* Get model class name | ||
* @return string | ||
*/ | ||
protected function getModelClass() : string | ||
{ | ||
return Offer::class; | ||
} | ||
|
||
/** | ||
* Get controller class name | ||
* @return string | ||
*/ | ||
protected function getControllerClass() : string | ||
{ | ||
return Offers::class; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php namespace Lovata\Shopaholic\Classes\Helper; | ||
|
||
use October\Rain\Support\Traits\Singleton; | ||
|
||
use Lovata\Shopaholic\Classes\Item\MeasureItem; | ||
use Lovata\Shopaholic\Models\Settings; | ||
|
||
/** | ||
* Class MeasureHelper | ||
* @package Lovata\Shopaholic\Classes\Helper | ||
* @author Andrey Kharanenka, [email protected], LOVATA Group | ||
*/ | ||
class MeasureHelper | ||
{ | ||
use Singleton; | ||
|
||
/** | ||
* Get dimensions unit measure | ||
* @return MeasureItem | ||
*/ | ||
public function getDimensionsMeasureItem() | ||
{ | ||
$iMeasureID = Settings::getValue('dimensions_measure'); | ||
$obMeasureItem = MeasureItem::make($iMeasureID); | ||
|
||
return $obMeasureItem; | ||
} | ||
|
||
/** | ||
* Get weight unit measure | ||
* @return MeasureItem | ||
*/ | ||
public function getWeightMeasureItem() | ||
{ | ||
$iMeasureID = Settings::getValue('weight_measure'); | ||
$obMeasureItem = MeasureItem::make($iMeasureID); | ||
|
||
return $obMeasureItem; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.