• Toshi Yoshida

    (@mikeg9999)


    Hi,

    At WPEC 3.11.2 when a customer first goes to the checkout page (i.e. no website cookies were previously present) the Billing country selection shows as ‘New Zealand’ and the Shipping country shows as ‘New Zealand’ which is correct – it’s the only country available for either field.

    When the customer fills out the billing details then ticks the ‘same as billing address’ box WPEC then invokes the ‘Calculate Shipping Price’ functionality. This results in the checkout page scolling up to the calulator, removing the shipping and total order price and displaying “Please click the Calculate button to refresh your shipping quotes, as your shipping information has been modified.”

    The problem here is that all that is unnecessary and confusing to the customer – the shipping country may have been updated(?) by ticking the ‘same as billing address’ box BUT the country actually didn’t and can’t change. It can only be New Zealand.

    (1) Can the plugin be made to test if the ‘updated’ value is the same as the original value and NOT invoke the ‘Calculate Shipping Price’ functionality?

    (2) Perhaps if the checkout page ‘same as billing address’ box was checked by default then this issue might not exist as the addresses would be the same on entry to the checkout page? Is there any way to do this?

    Thanks, Mike.

    https://wordpress.org/plugins/wp-e-commerce/

Viewing 2 replies - 1 through 2 (of 2 total)
  • GREAT call. I was researching all the other topics on this, since author has not fixed it.

    And this is the answer. I added JS to my wordpress system, to resolve this issue:

    $(document).ready(function() {
       if (!jQuery('input[type=checkbox][name*="shippingSameBilling"]').prop('checked')) jQuery('input[type=checkbox][name*="shippingSameBilling"]').trigger('click');
    });

    I had not thought of that, until you que’d it. Thanks!!
    So basically it forces it to be checked by default. I would rather force people to click a checkbox and retype values, than suffer this impassable error.

    Here’s my complete fix for this issue.

    <script type="text/javascript">
    
    // include this function somewhere
    function WPECOM_BUGFIX(options) {
    	var target=jQuery('input[type=checkbox][name*="shippingSameBilling"]');
    	if (target.length > 0) {
    
    		if (options.force_shippingSameAsBilling) {
    			if (!target.prop('checked')) target.trigger('click'); // have to trigger click, as the .prop() won't hide the inputs automatically.
    		}
    
    		if (options.force_valueMatch) {
    
    			var form=$('form.wpsc_checkout_forms');
    			form.on('submit',function(event) {
    				if (options.force_valueMatch) {
    					if (target.prop('checked')) {
    						var billing_root=form.find('table input[data-wpsc-meta-key^="billing"]:not(.wpsc-meta-value):first').parents('table');
    						var shipping_root=form.find('table input[data-wpsc-meta-key^="shipping"]:not(.wpsc-meta-value):first').parents('table');
    						shipping_root.find('input[data-wpsc-meta-key*="i"]') // all of them have a letter i in their attribute(sh[i]pping, b[i]lling). This is simply to test for existence of the attribute, without having to run a jquery filter. Because none of these share a class or anything to identify them distinctly....
    						.each(function() {
    							var ident=$(this).data('wpscMetaKey').replace('shipping','');
    							var assigned_el=billing_root.find('input[data-wpsc-meta-key*="'+ident+'"]'); // find the associated billing input.
    							var assigned_value=assigned_el.val();
    							$(this).val(assigned_value); // copy it's value over.
    						});
    					}
    				}	
    
    			});
    		}
    	}
    }
    
    </script>

    and the execution on page load..

    $(document).ready(function() {
    	// call this on page load.
    	// both options should be turned on, in order to fix the issue with AutoComplete filling entries without keystroke events, and to prevent php errors in WPEcom from failed submit forms.
    	// this is due to incorrect validation when Shipping should be same as Billing. An ongoing issue for at least 8 months.
    	WPECOM_BUGFIX({
    		force_shippingSameAsBilling: true, // enable the checkbox by default, to support the following two methods. User will have to uncheck it to enter shipping info.
    		force_valueMatch: true // force the values of shipping to match billing
    	});
    });

    Am unsure why the php code hasn’t been updated for this. It shouldn’t be validating form fields whose values are empty due to a conditional checkbox.
    So the above code simply copies the values over, onSubmit. Preventing user difficulty. They have simply to uncheck the box if they wish to input shipping information.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘'same as billing address' issue on checkout page’ is closed to new replies.