• Resolved amishdirect

    (@amishdirect)


    Is it possible to add the brand name to a product as either a new column or part of their options that show in the cart/checkout/order?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @amishdirect

    I’m afraid that plugin cannot edit your current layout, but hooks to it.

    Regards

    Thread Starter amishdirect

    (@amishdirect)

    Checking back in on this. Is there a hook I can have the plugin tie into so each product shows the brand on the order page/checkout/order email?

    Thread Starter amishdirect

    (@amishdirect)

    In case anyone wants to know I figured it out. You can display the brand name on checkout and email notifications.

    // Display order items product brands (Orders on front end and emails)
    add_action( 'woocommerce_order_item_meta_end', 'display_custom_data_in_emails', 10, 4 );
    function display_custom_data_in_emails( $item_id, $item, $order, $bool ) {
        // Get the product brands for this item
        $terms = wp_get_post_terms( $item->get_product_id(), 'pwb-brand', array( 'fields' => 'names' ) );
    
        // Output a coma separated string of product brand names
        echo "<br><small>" . implode(', ', $terms) . "</small>";
    }
    
    // Display order items product brands in admin order edit pages
    add_action( 'woocommerce_after_order_itemmeta', 'custom_admin_order_itemmeta', 15, 3 );
    function custom_admin_order_itemmeta( $item_id, $item, $product ){
        //if( ! is_admin() ) return; // only backend
    
        // Target order "line items" only to avoid errors
        if( $item->is_type( 'line_item' ) ){
            // Get the product brands for this item
            $terms = wp_get_post_terms( $item->get_product_id(), 'pwb-brand', array( 'fields' => 'names' ) );
    
            // Output a coma separated string of product brand names
            echo "<br><small>" . implode(', ', $terms) . "</small>";
        }
    }

    It was as simple as displaying categories and changing it over to display the brand instead.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Brand Name on Product Order’ is closed to new replies.