Display a selected custom product option in WooCommerce cart


I am using the code below to display a custom select field on WooCommerce single product pages:

<?php $sizes = $product->get_attribute( 'size' ); $sizes = explode(", ",$sizes); ?>
<?php if($sizes[0]!=''){ // if product sizes are available ?>
    <span class="product-size-label">Choose your size:</span>
    <select class="product-size">
    <?php foreach($sizes as $size){ ?>
        <option><?php echo $size; ?></option>
    <?php } ?>
<?php } ?>

Now need get the selected size and display it in cart page below title.

How can I do that for simple products type?

I don’t want use variation products.

, , Lerry 2 years 2020-08-29T13:10:30-05:00 0 Answers 53 views 0

Leave an answer