• I want to know how I can get the input type text value selected in product page in cart page without HTML. Its coming in cart page but I want to get the value and store in variable with all cart prducts

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hello,

    You just want to store the text value that goes to the cart in a variable?

    Thread Starter Abhilesh

    (@johndoe23292)

    Hi,
    Thanks for quick reply,
    Yes, I want to get this value in cart page with all products as I am working on cart.php file and need to get this textbox value as variable so I can use this.

    Thread Starter Abhilesh

    (@johndoe23292)

    Hi,
    After spending 1-2 day I have done this with code below.

    $string0 = apply_filters( 'woocommerce_cart_item_name', (method_exists( $_product, '' ) ?  : ''), $cart_item, $cart_item_key );
    $tags = array("dt");
    $string1 =  preg_replace('#<(' . implode( '|', $tags) . ')(?:[^>]+)?>.*?</\1>#s', '', $string0);
    echo $p_text = strip_tags($string1);

    There should be a better way to do this.

    Thanks

    Please give this a try and tell me if it suits you

    // DEBUG INPUT FIELDS
    add_filter( 'woocommerce_get_cart_item_from_session',   function( $item, $values, $key ){
    	error_log('product_id: '.$item['product_id']);	
    	$scopes = array('global','local');	
    	foreach ($scopes as $key => $scope) {
    		error_log('----');
    		error_log('scope: '.$scope);
    		if(isset($values["alg_wc_pif_{$scope}"])){			
    			foreach($values["alg_wc_pif_{$scope}"] as $input){
    				error_log('field_n: '.$input['_field_nr']);
    				error_log('field_title: '.$input['title']);				
    				error_log('value: '.$input['_value']);
    			}
    		}
    	}
    	return $item;
    }, PHP_INT_MAX, 3 );
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Query on how to get the input type text value in cart page without HTML’ is closed to new replies.