Support

Account

Home Forums General Issues Woocommerce Attribute Function Question

Helping

Woocommerce Attribute Function Question

  • Hello,

    I am working on a site that has utilized ACF to create the option to select multiple product option. The reason for this is twofold.
    1) The number of variables possible of a product with choice of up to 7 different color options choosing from 60+ colors is asttonomical
    2) Cleaner layout.

    The problem is, once the colors are selected, there is no record on the product page, cart, or order that shows what colors were selected which makes it impossible to take orders.

    Any thoughts on this?

    Here is a test product to show what is done so far:
    https://bigbanglestheory.com/product/ds-bangle/

    Thanks!
    Michael

  • Hi Michael,

    Using a custom function hooked to the woocommerce_before_order_itemmeta action hook, you could make it possible to achieve what you are looking for:

    add_action( 'woocommerce_before_order_itemmeta', 'storage_location_of_order_items', 10, 3 );
    function storage_location_of_order_items( $item_id, $item, $product ){
        // Only in backend Edit single Order pages
        if( current_user_can('edit_shop_orders') ):
    
        // The product ID (in WooCommerce 3+)
        $product_id = $product->get_id();
    
        // Get your ACF product value (replace the slug by yours below)
        $acf_value = __('Stored in: ') . get_field( 'BinLocation', $product_id );
    
        // Outputing the value of the "location storage" for this product item
        echo '<div class="wc-order-item-custom"><strong>'. $acf_value .'</strong></div>';
    
        endif;
    }
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Woocommerce Attribute Function Question’ is closed to new replies.