WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
Add custom varible to cart content (1 post)

  1. wpraj
    Member
    Posted 4 months ago #

    Hi Guys,

    I have added a custom variable in the product detail page and I can pass the custom variable value into add to cart function.

    public function add_to_cart( $product_id, $quantity = 1, $mmCentre, $variation_id = '', $variation = '', $cart_item_data = array()  ) {
    .........
    .........
    }

    So variable $mmid is the custom variable.Now I have done this

    $this->cart_contents[$cart_item_key] = apply_filters( 'woocommerce_add_cart_item', array_merge( $cart_item_data, array(
    					'product_id'	=> $product_id,
    					'variation_id'	=> $variation_id,
    					'variation' 	=> $variation,
    					'quantity' 		=> $quantity,
    					'data'			=> $product_data,
    					'mmCentre' 		=> $mmCentre
    				) ), $cart_item_key );

    The problem is I can't get that value in cart page.I did a dump of cart_contents but it's not adding in the array.

    Can you please suggest me what is the wrong I am doing.

    Thank you.

    https://wordpress.org/plugins/woocommerce/

Reply

You must log in to post.

About this Plugin

About this Topic