Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter danomurray

    (@danomurray)

    Hi there,

    Just wondering if there’s any update on the progress of the Pro release?

    Thanks,

    Dan.

    Thread Starter danomurray

    (@danomurray)

    Hi Sark,

    Thanks very much for your help and for the code update – I have installed the update and enabled the Client Side Validation.

    I am using the cloning fields feature (which is great), and I have an email address for each item added to the basket. So if the quantity is 2 then there are 2 email address fields, and I need to ensure that the same email address is not entered in more than one field. To achieve this I have in place my custom validation:

    add_action('woocommerce_add_to_cart_validation', array($this, 'validate_order_meta_data'), 10, 3);
    
    function validate_order_meta_data($valid, $product_id, $quantity)
    {
    	$values = array();
    
    	// for each quantity of item added to cart check whether the meta value is unique
    	for ($i = 0; $i < $quantity; $i++)
    	{
    		// request params are built from the field name and a base 1 index
    		$request_key_index = $i + 1;
    		$request_key = "email_$request_key_index";
    		if (isset($_REQUEST[$request_key]))
    		{
    			$value = $_REQUEST[$request_key];
    			// check for duplication
    			if (in_array($value, $values))
    			{
    				wc_add_notice("Value $value appears multiple times", 'error');
    				$valid = false;
    			}
    			else
    			{
    				$values[] = $value;
    			}
    		}
    	}
    
    	return $valid;
    }

    At the moment, if my custom validation fails then I see the validation error message shown, but my email address field values are cleared. Can I achieve what I want (my custom validation but not clearing the email address fields) using the new Client Side Validation?

    Thanks again for your help,

    Dan.

    Thread Starter danomurray

    (@danomurray)

    Hi Sark,

    Thanks for the quick reply and it’s great that this can be in a future release.

    I actually meant a quick update in terms of information rather than code but if you can provide a quick code update then even better!

    Thanks again,

    Dan.

    Thread Starter danomurray

    (@danomurray)

    Hi,

    Just wondered if it was possible to get a quick update – is this something that is already possible or will be possible in a future version, or should we be looking to find a different solution?

    Thanks,

    Dan.

Viewing 4 replies - 1 through 4 (of 4 total)