Forum Replies Created

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter authoritytactical

    (@authoritytactical)

    Ok. Is this something that you would consider adding? Did you check out the article I attached?

    Thread Starter authoritytactical

    (@authoritytactical)

    Great! I’ll pass it along…

    Thread Starter authoritytactical

    (@authoritytactical)

    Sure. The developer is a great guy. I’ll try and send him over here. I’ve only contacted him though his ticketing system. I could also pass along your email if you’d like…

    Thread Starter authoritytactical

    (@authoritytactical)

    Damn scratch that. retina.js method doesn’t work at all after clearing my caches (had forgot to clear assets on my CDN)…

    Thread Starter authoritytactical

    (@authoritytactical)

    I actually made a statement that might not be true above. I’ve been playing around with stuff and it looks like the retina.js method should work but it’s not. When I look at the “net” console in firebug I see that the @2x assets are being loaded, but they aren’t being put into the image tags on the page (even on the front page where WooThumbs is inactive). Do you have any idea why the image tags aren’t being affected?

    I figured out that it is a sub-plugin. You have to have the main agreeable plugin activated. It would be nice if the author would make this clear…

    Thread Starter authoritytactical

    (@authoritytactical)

    Ok. Thanks. I’ll just use a bit of jQuery to do it for now…

    Thread Starter authoritytactical

    (@authoritytactical)

    This is the code that I’m using in my functions.php file to add the name fields BTW:

    <?php
    /**  ----------------------------------------------------------
     * Add new register fields for WooCommerce registration.
     *
     * @return string Register fields HTML.
     *
     * Instructions from here:
     * https://support.woothemes.com/hc/en-us/articles/203182373-How-to-add-custom-fields-in-user-registration-on-the-My-Account-page
     * ----------------------------------------------------------------- */
    
    function wooc_extra_register_fields() {
    /* I'm using FNAME as the field name for firstname so that MailChimp receives it  */
    	?>
    <p class="form-row form-row-first">
    	<label for="reg_billing_first_name"><?php _e( 'First name', 'woocommerce' ); ?> <span class="required">*</span></label>
    	<input type="text" class="input-text" name="mc4wp-FNAME" id="reg_billing_first_name" value="<?php if ( ! empty( $_POST['mc4wp-FNAME'] ) ) esc_attr_e( $_POST['mc4wp-FNAME'] ); ?>" />
    	</p>
    
    	<p class="form-row form-row-last">
    	<label for="reg_billing_last_name"><?php _e( 'Last name', 'woocommerce' ); ?> <span class="required">*</span></label>
    	<input type="text" class="input-text" name="mc4wp-LNAME" id="reg_billing_last_name" value="<?php if ( ! empty( $_POST['billing_last_name'] ) ) esc_attr_e( $_POST['billing_last_name'] ); ?>" />
    	</p>
    
    	<div class="clear"></div>
    
    	<?php
    }
    
    add_action( 'woocommerce_register_form_start', 'wooc_extra_register_fields' );
    
    /**
     * Validate the extra register fields.
     *
     * @param  string $username          Current username.
     * @param  string $email             Current email.
     * @param  object $validation_errors WP_Error object.
     *
     * @return void
     */
    
    function wooc_validate_extra_register_fields( $username, $email, $validation_errors ) {
    	if ( isset( $_POST['mc4wp-FNAME'] ) && empty( $_POST['mc4wp-FNAME'] ) ) {
    		$validation_errors->add( 'billing_first_name_error', __( '
    		<strong>Error</strong>: First name is required!', 'woocommerce' ) );
    	}
    
    	if ( isset( $_POST['billing_last_name'] ) && empty( $_POST['billing_last_name'] ) ) {
    		$validation_errors->add( 'billing_last_name_error', __( '<strong>Error</strong>: Last name is required!.', 'woocommerce' ) );
    	}
    
    }
    
    add_action( 'woocommerce_register_post', 'wooc_validate_extra_register_fields', 10, 3 );
    
    /**
     * Save the extra register fields.
     *
     * @param  int  $customer_id Current customer ID.
     *
     * @return void
     */
    function wooc_save_extra_register_fields( $customer_id ) {
    	if ( isset( $_POST['mc4wp-FNAME'] ) ) {
    		// WordPress default first name field.
    		update_user_meta( $customer_id, 'first_name', sanitize_text_field( $_POST['mc4wp-FNAME'] ) );
    
    		// WooCommerce billing first name.
    		update_user_meta( $customer_id, 'billing_first_name', sanitize_text_field( $_POST['mc4wp-FNAME'] ) );
    
    			// Set default display name.
    		update_user_meta( $customer_id, 'nickname', sanitize_text_field( $_POST['mc4wp-FNAME'] ) );
    	}
    
    	if ( isset( $_POST['billing_last_name'] ) ) {
    		// WordPress default last name field.
    		update_user_meta( $customer_id, 'last_name', sanitize_text_field( $_POST['billing_last_name'] ) );
    
    		// WooCommerce billing last name.
    		update_user_meta( $customer_id, 'billing_last_name', sanitize_text_field( $_POST['billing_last_name'] ) );
    	}
    }
    
    add_action( 'woocommerce_created_customer', 'wooc_save_extra_register_fields' );
    
    /*  ---- this code sets the first name as the display name ---- */
    add_filter('pre_user_display_name','default_display_name');
    
    function default_display_name($name) {
    
    		  if ( isset( $_POST['mc4wp-FNAME'] ) ) {
    		   $name = sanitize_text_field( $_POST['mc4wp-FNAME'] );
    }
     return $name;
    }
    ?>
Viewing 8 replies - 1 through 8 (of 8 total)