Skip to content

Instantly share code, notes, and snippets.

@unlocomqx
Created January 30, 2024 19:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unlocomqx/79630ebb7dc3f57bbb92c4c3419cc650 to your computer and use it in GitHub Desktop.
Save unlocomqx/79630ebb7dc3f57bbb92c4c3419cc650 to your computer and use it in GitHub Desktop.
Read option sku
<?php
/** @var $id_product */
/* @var DynamicInputField[] $input_fields */
/* @var $dropdown */
/* @var $dropdown_ref */
use DynamicProduct\classes\models\dynamic_fields\DropDownField;
use DynamicProduct\classes\models\DynamicField;
use DynamicProduct\classes\models\DynamicInputField;
$selected_option = $input_fields['dropdown']->selected_options[0] ?? null;
if ($selected_option) {
/** @var DropDownField $field */
$field = DynamicField::getFieldByName($id_product, 'dropdown');
$option = $field->options[$selected_option] ?? null;
if ($option) {
$dropdown_ref = $option['sku'];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment