0
votes

For my products, I need to create custom options (with ACF pro plugin). The custom options can be checkboxes or radio buttons, each option is associated with a number value (an addon price).

What I want to do is add the number field to the total product price with Ajax. Here is my ACF html code :

<div class="option-wrapper">
   <?php if( have_rows('product_options') ): while ( have_rows('product_options') ) : the_row(); ?>
        <div class="color-wrapper">
            <?php if( have_rows('couleur') ): while( have_rows('couleur') ): the_row();?>

                <div class="color-dot" style="background-color:<?php echo get_sub_field('type_couleur');?>"></div>

            <?php endwhile; endif; ?>

        </div>

        <div class="stockage-wrapper">
            <?php if( have_rows('stockage') ): while( have_rows('stockage') ): the_row();?>
                <div class="stockage-dot">
                  <label class="stockage-label">
                      <input type="radio" name="stockage" id="<?php echo get_sub_field('id_stockage');?>" value="<?php echo get_sub_field('id_stockage');?>" class="stockage-radio"/>
                      <span><?php echo get_sub_field('valeur_stockage');?></span>
                  </label>
                </div>
            <?php endwhile; endif; ?>
        </div>
   <?php endwhile; endif; ?>
</div>

Link to my test single product page

Any idea how I can make it happen ? Best regards

1

1 Answers

0
votes

I'm pretty sure you have to use variable products for that (with attributes like color etc)

You can then use that guide: https://quadmenu.com/add-to-cart-with-woocommerce-and-ajax-step-by-step/