1

I have created custom field in custom option by using

custom option, custom fields

I want to get my custom option from $block->getOption();

But my custom field not added in the list ..

Thanks.

1

Try this....

$_product = $block->getProduct();
foreach ($_product->getOptions() as $o) {
    if ($o->getTitle() != 'Color') { // or another title of option
        continue;
    }
    foreach ($o->getValues() as $value) {
        print_r($value->getData());
    }
}
  • I have add is_default field in custom option .... I want to default select the radio button which option values has is_default= 1..How to do this... – Mano M Dec 22 '18 at 6:29
  • is_default is custom options title or value – Sarvesh Tiwari Dec 22 '18 at 6:52
  • title ......... – Mano M Dec 22 '18 at 6:57
  • try this if ($o->getTitle() == 'is_default') { //your conditions continue; } – Sarvesh Tiwari Dec 22 '18 at 8:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.