woocommerce offtopic - How to customize product at cart page

admin2025-06-06  5

I want to add some extra field in the cart page. i mean when a user add some product into cart and pressed view cart button then he can see his selected product with some default field image product price and total but I want add extra field where user can choose an option to get product monthly or weekly. So I want to add an option drop down for each product in the cart page.I saw some plugin but all are working on checkout pages not cart page. So how can I add extra field into the cart page.

I want to add some extra field in the cart page. i mean when a user add some product into cart and pressed view cart button then he can see his selected product with some default field image product price and total but I want add extra field where user can choose an option to get product monthly or weekly. So I want to add an option drop down for each product in the cart page.I saw some plugin but all are working on checkout pages not cart page. So how can I add extra field into the cart page.

Share Improve this question edited Nov 15, 2018 at 16:22 fuxia 107k39 gold badges255 silver badges461 bronze badges asked Nov 15, 2018 at 12:00 Md. Abu ZamanMd. Abu Zaman 1251 silver badge4 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

use this function and edit cart page template

/**
 * Display engraving text in the cart.
 *
 * @param array $item_data
 * @param array $cart_item
 *
 * @return array
 */
function iconic_display_engraving_text_cart( $item_data, $cart_item ) {
    if ( empty( $cart_item['iconic-engraving'] ) ) {
        return $item_data;
    }

    $item_data[] = array(
        'key'     => __( 'Engraving', 'iconic' ),
        'value'   => wc_clean( $cart_item['iconic-engraving'] ),
        'display' => '',
    );

    return $item_data;
}

add_filter( 'woocommerce_get_item_data', 'iconic_display_engraving_text_cart', 10, 2 );
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749177262a317010.html

最新回复(0)