0

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.

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 );
  • I added your code at function.php but it nothing is happening. How can I add an extra filed with option button?? – Md. Abu Zaman Nov 18 '18 at 19:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.