I want to display configurable products associated simple product price in configurable product option.
I am attaching image as price display below the option value. If some one has did this task then help me.
configurable-productconfigurable-product-optionsmagento2product
Best Answer
Finally displayed price with configurable product option!!
I have debug the code and found configurable product swatch options come from below file.
So, I have overwrite "swatch-renderer.js" file into my custom theme. So, custom them path would be.
Please change name "Vendor" and "default" as per your theme name.
Now, I have debug the code of swatch-renderer.js file and found options value generate using "_RenderSwatchOptions" function. So, I have made below changes.
Change #1: "_RenderSwatchOptions" do not get data of $widget veriable. So, I have make below change.
Befor:
After my change:
Change #2: search with "_RenderSwatchOptions" and change argument from where this function call from "swatch-renderer.js" file
Before:
After my change:
Change #3: Now I can get the value of $widget object in to "_RenderSwatchOptions" function but not abel to get price value of options.
So, to add option id wise price please add below code below the line change which applied in #2.
Before:
After my change:
Change #4: Add price div into "_RenderSwatchOptions" function.
My attribute is swatch options with type = text. So, I made below changes.
Before:
After my change:
Might be my post help someone who want to make change in configurable products options.
Thanks.