I have made a custom button that would be shown on the Product details page instead of the "Add to Cart" button. Now on clicking that button, I want to show some customizable options that are going to be hidden initially. I could not find a way to Hide/Show customizable options, I only found the code to create customizable options programmatically

$valuesArray = array();
//add as many options you want, here we add two
$valuesArray[] = array(
    "title"       => "Option1", 
    "price_type"  => "fixed", 
    "price"       => 9.99,
    "sku"         => $product->getSku(),
    "sort_order"  =>; 1,
$valuesArray[] = array(
    "title"       => "Option2", 
    "price_type"  => "fixed", 
    "price"       => 1.99,
    "sku"         => $product->getSku(),
    "sort_order"  => 2,
//now we create options and set type
$options[] = array(
    "sort_order"    => 1,
    "title"         => "Options",
    "type"          => "radio",
    "is_require"    => 1,
    "values"        => $valuesArray,
foreach ($options as $arrayOption) {
    $option = $this->_objectManager->create('\Magento\Catalog\Model\Product\Option')
    $options[] = $option;

which is also not working. Is there a way, so that I can hide some customizable options when the user goes to the product detail page and unhide them when he clicks the custom button

Your Answer

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

Browse other questions tagged or ask your own question.