enter image description here - Product is eligible for purchase and lease - purchase price is 240 - lease price is 24 per month (240 for 240 months)

1. How to make price dependent with this custom option with main price


  1. If Option is purchase then price will be 240
  2. If option will be lease the price will be Main price/Rental Term

2. How to make combination price for Rental Term and Service (Both are product custom option)


You have to purchase the dependent custom option extension Or create the custom module. Link for extension,

  1. https://shop.emiprotechnologies.com/dependent-custom-options-for-magento-2.html

  2. https://bsscommerce.com/magento-2-dependent-custom-options-extension.html

  3. https://www.mageworx.com/magento-2-advanced-product-options-suite.html (Recommended)..

If you want to create the custom functionality for set the custom price based on the selection then you must need to set the price using the observer.

I don't have checked this code works or not but you can use the logic.Please don't use object manager as well.You need to create the block file to get the product collection.

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$product = $objectManager->create('Magento\Catalog\Model\Product')->load($product_id);

$values = array();
foreach ($product->getOptions() as $o) {
           $p = $o->getValues();
  foreach($p as $v)
            $values[$v->getId()]['option_type_id']= $v->getId();
                $values[$v->getId()]['title']= 'test';
                $values[$v->getId()]['price']= 23;
                $values[$v->getId()]['price_type']= 'fixed';
                $values[$v->getId()]['sku']= $value1;

  • I want to create custom module, any suggestion for that ? – Aditya Shah Oct 23 '18 at 6:35
  • Please check my updated answer! – Sunny Rahevar Oct 23 '18 at 6:44
  • Thanks a lot for the efforts :) i will check it and update you soon!!! – Aditya Shah Oct 23 '18 at 6:47

Custom options are one of the inseparable parts of a product in Magento. Store owners often need to offer custom options dependent on each other. For ex., you need to show 'Green' color only when the size 'Large' is selected.

I recommend Dependant custom option Magento Extension to you. This extension facilitates admin to show or hide the custom options based on a selection of the parent custom options. Admin can quickly set the dependency relation between the custom options. Admin can select which custom option will behave as a parent and which as a child.

I hope this will help.

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.