-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
18b6a09
commit 4aa9184
Showing
9 changed files
with
547 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace DevStone\UsageCalculator\Model\AdminOrder; | ||
|
||
class Create extends \Magento\Sales\Model\AdminOrder\Create | ||
{ | ||
/** | ||
* @param $item | ||
* @return array|mixed | ||
*/ | ||
protected function _prepareOptionsForRequest($item) | ||
{ | ||
$usageOptions = $item->getOptionByCode('usage_options'); | ||
if($usageOptions && $usageOptions->hasData('value')) { | ||
return json_decode($usageOptions->getValue(), true); | ||
} | ||
return parent::_prepareOptionsForRequest($item); | ||
} | ||
} |
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,8 @@ | ||
|
||
var config = { | ||
map: { | ||
'*': { | ||
usage: 'DevStone_UsageCalculator/usage' | ||
} | ||
} | ||
}; |
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,53 @@ | ||
<?php | ||
// @codingStandardsIgnoreFile | ||
|
||
?> | ||
<?php $_option = $block->getOption() ?> | ||
<?php $_optionId = $_option->getId() ?> | ||
<?php $class = ($_option->getIsRequire()) ? ' required' : ''; ?> | ||
<div class="field date<?= /* @escapeNotVerified */ $class ?>" | ||
data-mage-init='{"priceOptionDate":{"fromSelector":"#product_addtocart_form"}}'> | ||
<fieldset class="fieldset fieldset-product-options-inner<?= /* @escapeNotVerified */ $class ?>"> | ||
<legend class="legend"> | ||
<span><?= $block->escapeHtml($_option->getTitle()) ?></span> | ||
<?= /* @escapeNotVerified */ $block->getFormatedPrice() ?> | ||
</legend> | ||
<div class="control"> | ||
<?php if ($_option->getType() == \Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_TYPE_DATE_TIME | ||
|| $_option->getType() == \Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_TYPE_DATE): ?> | ||
|
||
<?= $block->getDateHtml() ?> | ||
|
||
<?php endif; ?> | ||
|
||
<?php if ($_option->getType() == \Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_TYPE_DATE_TIME | ||
|| $_option->getType() == \Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_TYPE_TIME): ?> | ||
<?= $block->getTimeHtml() ?> | ||
<?php endif; ?> | ||
|
||
<?php if ($_option->getIsRequire()): ?> | ||
<input type="hidden" | ||
name="validate_datetime_<?= /* @escapeNotVerified */ $_optionId ?>" | ||
class="validate-datetime-<?= /* @escapeNotVerified */ $_optionId ?>" | ||
value="" | ||
data-validate="{'validate-required-datetime':<?= /* @escapeNotVerified */ $_optionId ?>}"/> | ||
<?php else: ?> | ||
<input type="hidden" | ||
name="validate_datetime_<?= /* @escapeNotVerified */ $_optionId ?>" | ||
class="validate-datetime-<?= /* @escapeNotVerified */ $_optionId ?>" | ||
value="" | ||
data-validate="{'validate-optional-datetime':<?= /* @escapeNotVerified */ $_optionId ?>}"/> | ||
<?php endif; ?> | ||
<script type="text/x-magento-init"> | ||
{ | ||
"#product_addtocart_form": { | ||
"validation": { | ||
"ignore": ":hidden:not(input[name^='validate_datetime_'])" | ||
} | ||
} | ||
} | ||
</script> | ||
</div> | ||
</fieldset> | ||
|
||
</div> |
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,9 @@ | ||
<?php | ||
|
||
// @codingStandardsIgnoreFile | ||
|
||
?> | ||
<?php $_option = $block->getOption() ?> | ||
<div class="field"> | ||
<label class="label"><span><?= $block->escapeHtml($_option->getTitle()) ?></span></label> | ||
</div> |
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,63 @@ | ||
<?php | ||
|
||
// @codingStandardsIgnoreFile | ||
|
||
?> | ||
<?php $_option = $block->getOption(); ?> | ||
<?php $_fileInfo = $block->getFileInfo(); ?> | ||
<?php $_fileExists = $_fileInfo->hasData(); ?> | ||
<?php $_fileName = 'options_' . $_option->getId() . '_file'; ?> | ||
<?php $_fieldNameAction = $_fileName . '_action'; ?> | ||
<?php $_fieldValueAction = $_fileExists ? 'save_old' : 'save_new'; ?> | ||
<?php $_fileNamed = $_fileName . '_name'; ?> | ||
<?php $class = ($_option->getIsRequire()) ? ' required' : ''; ?> | ||
|
||
<div class="field file<?= /* @escapeNotVerified */ $class ?>"> | ||
<label class="label" for="<?= /* @noEscape */ $_fileName ?>" id="<?= /* @noEscape */ $_fileName ?>-label"> | ||
<span><?= $block->escapeHtml($_option->getTitle()) ?></span> | ||
<?= /* @escapeNotVerified */ $block->getFormatedPrice() ?> | ||
</label> | ||
<?php if ($_fileExists): ?> | ||
<div class="control"> | ||
<span class="<?= /* @noEscape */ $_fileNamed ?>"><?= $block->escapeHtml($_fileInfo->getTitle()) ?></span> | ||
<a href="javascript:void(0)" class="label" id="change-<?= /* @noEscape */ $_fileName ?>" > | ||
<?= /* @escapeNotVerified */ __('Change') ?> | ||
</a> | ||
<?php if (!$_option->getIsRequire()): ?> | ||
<input type="checkbox" id="delete-<?= /* @escapeNotVerified */ $_fileName ?>" /> | ||
<span class="label"><?= /* @escapeNotVerified */ __('Delete') ?></span> | ||
<?php endif; ?> | ||
</div> | ||
<?php endif; ?> | ||
<div class="control" id="input-box-<?= /* @escapeNotVerified */ $_fileName ?>" | ||
data-mage-init='{"priceOptionFile":{ | ||
"fileName":"<?= /* @noEscape */ $_fileName ?>", | ||
"fileNamed":"<?= /* @noEscape */ $_fileNamed ?>", | ||
"fieldNameAction":"<?= /* @escapeNotVerified */ $_fieldNameAction ?>", | ||
"changeFileSelector":"#change-<?= /* @escapeNotVerified */ $_fileName ?>", | ||
"deleteFileSelector":"#delete-<?= /* @escapeNotVerified */ $_fileName ?>"} | ||
}' | ||
<?= $_fileExists ? 'style="display:none"' : '' ?>> | ||
<input type="file" | ||
name="<?= /* @escapeNotVerified */ $_fileName ?>" | ||
id="<?= /* @escapeNotVerified */ $_fileName ?>" | ||
class="product-custom-option<?= $_option->getIsRequire() ? ' required' : '' ?>" | ||
<?= $_fileExists ? 'disabled="disabled"' : '' ?> /> | ||
<input type="hidden" name="<?= /* @escapeNotVerified */ $_fieldNameAction ?>" value="<?= /* @escapeNotVerified */ $_fieldValueAction ?>" /> | ||
<?php if ($_option->getFileExtension()): ?> | ||
<p class="note"> | ||
<?= /* @escapeNotVerified */ __('Compatible file extensions to upload') ?>: <strong><?= /* @escapeNotVerified */ $_option->getFileExtension() ?></strong> | ||
</p> | ||
<?php endif; ?> | ||
<?php if ($_option->getImageSizeX() > 0): ?> | ||
<p class="note"> | ||
<?= /* @escapeNotVerified */ __('Maximum image width') ?>: <strong><?= /* @escapeNotVerified */ $_option->getImageSizeX() ?> <?= /* @escapeNotVerified */ __('px.') ?></strong> | ||
</p> | ||
<?php endif; ?> | ||
<?php if ($_option->getImageSizeY() > 0): ?> | ||
<p class="note"> | ||
<?= /* @escapeNotVerified */ __('Maximum image height') ?>: <strong><?= /* @escapeNotVerified */ $_option->getImageSizeY() ?> <?= /* @escapeNotVerified */ __('px.') ?></strong> | ||
</p> | ||
<?php endif; ?> | ||
</div> | ||
</div> |
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,27 @@ | ||
<?php | ||
|
||
// @codingStandardsIgnoreFile | ||
|
||
?> | ||
|
||
<?php /* @var $block \DevStone\UsageCalculator\Block\Usage\View\Options\Type\Select */ ?> | ||
<?php | ||
$_option = $block->getOption(); | ||
$class = ($_option->getIsRequire()) ? ' required' : ''; | ||
?> | ||
<div class="field<?= /* @escapeNotVerified */ $class ?>"> | ||
<label class="label" for="select_<?= /* @escapeNotVerified */ $_option->getId() ?>"> | ||
<span><?= $block->escapeHtml($_option->getTitle()) ?>:</span> <a href="#" data-less="<?= __('less info') ?>" tabindex="-1"><?= __('more info') ?></a> | ||
</label> | ||
<div class="help-text"> | ||
<?= $block->escapeHtml($_option->getHelp()); ?> | ||
</div> | ||
<div class="control"> | ||
<?= $block->getValuesHtml() ?> | ||
<?php if ($_option->getIsRequire()): ?> | ||
<?php if ($_option->getType() == \Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_TYPE_RADIO || $_option->getType() == \Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_TYPE_CHECKBOX): ?> | ||
<span id="options-<?= /* @escapeNotVerified */ $_option->getId() ?>-container"></span> | ||
<?php endif; ?> | ||
<?php endif;?> | ||
</div> | ||
</div> |
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,61 @@ | ||
<?php | ||
// @codingStandardsIgnoreFile | ||
|
||
?> | ||
<?php | ||
$_option = $block->getOption(); | ||
$class = ($_option->getIsRequire()) ? ' required' : ''; | ||
?> | ||
|
||
<div class="field<?php if ($_option->getType() == \Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_TYPE_AREA) { | ||
echo ' textarea'; | ||
} ?><?= /* @escapeNotVerified */ $class ?>"> | ||
<label class="label" for="options_<?= /* @escapeNotVerified */ $_option->getId() ?>_text"> | ||
<span><?= $block->escapeHtml($_option->getTitle()) ?>:</span> <a href="#" tabindex="-1" data-less="<?= __('less info') ?>">more info</a> | ||
</label> | ||
<div class="help-text"> | ||
<?= $block->escapeHtml($_option->getHelp()); ?> | ||
</div> | ||
<div class="control"> | ||
<?php if ($_option->getType() == \Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_TYPE_FIELD): ?> | ||
<?php $_textValidate = null; | ||
if ($_option->getIsRequire()) { | ||
$_textValidate['required'] = true; | ||
} | ||
if ($_option->getMaxCharacters()) { | ||
$_textValidate['maxlength'] = $_option->getMaxCharacters(); | ||
} | ||
$_textValidate['validate-no-utf8mb4-characters'] = true; | ||
?> | ||
<input type="text" | ||
id="options_<?= /* @escapeNotVerified */ $_option->getId() ?>_text" | ||
class="input-text product-custom-option" | ||
<?php if (!empty($_textValidate)) {?> | ||
data-validate="<?= $block->escapeHtml(json_encode($_textValidate)) ?>" | ||
<?php } ?> | ||
data-title="<?= $block->escapeHtmlAttr($_option->getTitle()) ?>" | ||
name="options[<?= /* @escapeNotVerified */ $_option->getId() ?>]" | ||
data-selector="options[<?= /* @escapeNotVerified */ $_option->getId() ?>]" | ||
value="<?= $block->escapeHtml($block->getDefaultValue()) ?>"/> | ||
<?php elseif ($_option->getType() == \Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_TYPE_AREA): ?> | ||
<?php $_textAreaValidate = null; | ||
if ($_option->getIsRequire()) { | ||
$_textAreaValidate['required'] = true; | ||
} | ||
if ($_option->getMaxCharacters()) { | ||
$_textAreaValidate['maxlength'] = $_option->getMaxCharacters(); | ||
} | ||
$_textAreaValidate['validate-no-utf8mb4-characters'] = true; | ||
?> | ||
<textarea id="options_<?= /* @escapeNotVerified */ $_option->getId() ?>_text" | ||
class="product-custom-option" | ||
<?php if (!empty($_textAreaValidate)) {?> | ||
data-validate="<?= $block->escapeHtml(json_encode($_textAreaValidate)) ?>" | ||
<?php } ?> | ||
name="options[<?= /* @escapeNotVerified */ $_option->getId() ?>]" | ||
data-selector="options[<?= /* @escapeNotVerified */ $_option->getId() ?>]" | ||
rows="5" | ||
cols="25"><?= $block->escapeHtml($block->getDefaultValue()) ?></textarea> | ||
<?php endif; ?> | ||
</div> | ||
</div> |
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,26 @@ | ||
<?php /* @var $block \DevStone\UsageCalculator\Block\Catalog\Product\Usage */ ?> | ||
<?php foreach ($block->getCategories() as $category): ?> | ||
<?php $usages = $block->getUsages($category) ?> | ||
|
||
<div class="category-container field" style="display:none;" id="category_container_<?= $category->getId() ?>"> | ||
<label class="label" for="usage_<?= $category->getId() ?>_usages"> | ||
<span><?= __('Specific Usage') ?>:</span> <a href="#" data-less="<?= __('less info') ?>" tabindex="-1"><?= __('more info') ?></a> | ||
</label> | ||
<div class="help-text"> | ||
<?= __('Choose the usage which best describes how you intend to use the image.') ?> | ||
</div> | ||
<div class="control"> | ||
<?= $block->getUsagesSelectHtml($usages, $category); ?> | ||
</div> | ||
</div> | ||
|
||
<?php foreach ($usages as $usage): ?> | ||
<div class="usage-container" style="display:none;" id="usage_container_<?= $usage->getId() ?>"> | ||
<?php foreach ($usage->getOptions() as $_option): ?> | ||
|
||
<?= $block->getOptionHtml($_option) ?> | ||
|
||
<?php endforeach; ?> | ||
</div> | ||
<?php endforeach; ?> | ||
<?php endforeach; ?> |
Oops, something went wrong.