Jump to content

Custom EDD Plugin PHP Code Isn't Saving...?


agh151

Recommended Posts

Hi there!

I'm very much new to the coding world, so please forgive any blunders. I'm in the process of setting up a BlueHost/Wordpress site, and am wanting to customize some code on the checkout page of a plugin I'm using. In my mind, it should be a relatively simple fix - I'm just trying to change the text and font, as it's pretty generic out of the box. I was able to edit the checkout cart itself just fine, but the changes to the form (a separate PHP file) simply aren't saving on the website. I've talked with BlueHost and they turned caching off, thinking that might be the issue, but no luck. Since everything on the server end is fine, I'm thinking it must be an error on my part. I've copied the original plugin file to a separate folder under my current theme, just as I did with the checkout cart, and this is the section of code I'm wanting to edit:

}

/**
 * Renders the Purchase Form, hooks are provided to add to the purchase form.
 * The default Purchase Form rendered displays a list of the enabled payment
 * gateways, a user registration form (if enable) and a credit card info form
 * if credit cards are enabled
 *
 * @since 1.4
 * @return string
 */
function edd_show_purchase_form() {
	$payment_mode = edd_get_chosen_gateway();

	/**
	 * Hooks in at the top of the purchase form
	 *
	 * @since 1.4
	 */
	do_action( 'edd_purchase_form_top' );

	if ( edd_can_checkout() ) {

		do_action( 'edd_purchase_form_before_register_login' );

		$show_register_form = edd_get_option( 'show_register_form', 'none' ) ;
		if( ( $show_register_form === 'registration' || ( $show_register_form === 'both' && ! isset( $_GET['login'] ) ) ) && ! is_user_logged_in() ) : ?>
			<div id="edd_checkout_login_register">
				<?php do_action( 'edd_purchase_form_register_fields' ); ?>
			</div>
		<?php elseif( ( $show_register_form === 'login' || ( $show_register_form === 'both' && isset( $_GET['login'] ) ) ) && ! is_user_logged_in() ) : ?>
			<div id="edd_checkout_login_register">
				<?php do_action( 'edd_purchase_form_login_fields' ); ?>
			</div>
		<?php endif; ?>

		<?php if( ( ! isset( $_GET['login'] ) && is_user_logged_in() ) || ! isset( $show_register_form ) || 'none' === $show_register_form || 'login' === $show_register_form ) {
			do_action( 'edd_purchase_form_after_user_info' );
		}

		/**
		 * Hooks in before Credit Card Form
		 *
		 * @since 1.4
		 */
		do_action( 'edd_purchase_form_before_cc_form' );

		if( edd_get_cart_total() > 0 ) {

			// Load the credit card form and allow gateways to load their own if they wish
			if ( has_action( 'edd_' . $payment_mode . '_cc_form' ) ) {
				do_action( 'edd_' . $payment_mode . '_cc_form' );
			} else {
				do_action( 'edd_cc_form' );
			}

		}

		/**
		 * Hooks in after Credit Card Form
		 *
		 * @since 1.4
		 */
		do_action( 'edd_purchase_form_after_cc_form' );

	} else {
		// Can't checkout
		do_action( 'edd_purchase_form_no_access' );
	}

	/**
	 * Hooks in at the bottom of the purchase form
	 *
	 * @since 1.4
	 */
	do_action( 'edd_purchase_form_bottom' );
}
add_action( 'edd_purchase_form', 'edd_show_purchase_form' );

/**
 * Shows the User Info fields in the Personal Info box, more fields can be added
 * via the hooks provided.
 *
 * @since 1.3.3
 * @return void
 */
function edd_user_info_fields() {

	$customer = EDD()->session->get( 'customer' );
	$customer = wp_parse_args( $customer, array( 'first_name' => '', 'last_name' => '', 'email' => '' ) );

	if( is_user_logged_in() ) {
		$user_data = get_userdata( get_current_user_id() );
		foreach( $customer as $key => $field ) {

			if ( 'email' == $key && empty( $field ) ) {
				$customer[ $key ] = $user_data->user_email;
			} elseif ( empty( $field ) ) {
				$customer[ $key ] = $user_data->$key;
			}

		}
	}

	$customer = array_map( 'sanitize_text_field', $customer );
	?>
	<fieldset id="edd_checkout_user_info">
		<legend><?php echo apply_filters( 'edd_checkout_personal_info_text', esc_html__( 'Contact Info', 'easy-digital-downloads' ) ); ?></legend>
		<?php do_action( 'edd_purchase_form_before_email' ); ?>
		<p id="edd-email-wrap">
			<label class="edd-label" for="edd-email">
				<?php esc_html_e( 'Email Address', 'easy-digital-downloads' ); ?>
				<?php if( edd_field_is_required( 'edd_email' ) ) { ?>
					<span class="edd-required-indicator">*</span>
				<?php } ?>
			</label>
			<span class="edd-description" id="edd-email-description"><?php esc_html_e( 'We will send the purchase receipt to this address.', 'easy-digital-downloads' ); ?></span>
			<input class="edd-input required" type="email" name="edd_email" placeholder="<?php esc_html_e( 'Email address', 'easy-digital-downloads' ); ?>" id="edd-email" value="<?php echo esc_attr( $customer['email'] ); ?>" aria-describedby="edd-email-description"<?php if( edd_field_is_required( 'edd_email' ) ) {  echo ' required '; } ?>/>
		</p>
		<?php do_action( 'edd_purchase_form_after_email' ); ?>
		<p id="edd-first-name-wrap">
			<label class="edd-label" for="edd-first">
				<?php esc_html_e( 'First Name', 'easy-digital-downloads' ); ?>
				<?php if( edd_field_is_required( 'edd_first' ) ) { ?>
					<span class="edd-required-indicator">*</span>
				<?php } ?>
			</label>
			<span class="edd-description" id="edd-first-description"><?php esc_html_e( 'We will use this to personalize your account experience.', 'easy-digital-downloads' ); ?></span>
			<input class="edd-input required" type="text" name="edd_first" placeholder="<?php esc_html_e( 'First Name', 'easy-digital-downloads' ); ?>" id="edd-first" value="<?php echo esc_attr( $customer['first_name'] ); ?>"<?php if( edd_field_is_required( 'edd_first' ) ) {  echo ' required '; } ?> aria-describedby="edd-first-description" />
		</p>
		<p id="edd-last-name-wrap">
			<label class="edd-label" for="edd-last">
				<?php esc_html_e( 'Last Name', 'easy-digital-downloads' ); ?>
				<?php if( edd_field_is_required( 'edd_last' ) ) { ?>
					<span class="edd-required-indicator">*</span>
				<?php } ?>
			</label>
			<span class="edd-description" id="edd-last-description"><?php esc_html_e( 'We will use this as well to personalize your account experience.', 'easy-digital-downloads' ); ?></span>
			<input class="edd-input<?php if( edd_field_is_required( 'edd_last' ) ) { echo ' required'; } ?>" type="text" name="edd_last" id="edd-last" placeholder="<?php esc_html_e( 'Last Name', 'easy-digital-downloads' ); ?>" value="<?php echo esc_attr( $customer['last_name'] ); ?>"<?php if( edd_field_is_required( 'edd_last' ) ) {  echo ' required '; } ?> aria-describedby="edd-last-description"/>
		</p>
		<?php do_action( 'edd_purchase_form_user_info' ); ?>
		<?php do_action( 'edd_purchase_form_user_info_fields' ); ?>
	</fieldset>
	<?php
}

 

I've tried to change "Personal Info" to "Contact Info", for example, in the code above - but still renders the original file.

Any help at all you all could provide would be fantastic. Thank you!

Link to comment
Share on other sites

Most of the time WordPress needs to show a label it does so through translations. "Personal Info" works as both the identifier for a particular translatable phrase as well as the default if there is no translation for it. Changing the code to say "Contact Info" changes the default, which you do want, but it also changes the identifier, which you don't want because then translations won't work for it.

Instead of changing the code, I suggest setting up a "translation" that turns the phrase "Personal Info" into "Contact Info".

And what did you want to do about fonts?

 

For the caching problem, either your browser is caching the page (try using privacy/incognito mode, a different browser, or even another device) or WordPress is caching it. Check if you have any plugins installed which might be doing that. Also check that you're editing the right files in the right places, and obviously that you're uploading the changed versions properly.

Link to comment
Share on other sites

On 6/3/2018 at 5:03 PM, requinix said:

"Personal Info" works as both the identifier for a particular translatable phrase as well as the default if there is no translation for it. Changing the code to say "Contact Info" changes the default, which you do want, but it also changes the identifier, which you don't want because then translations won't work for it.

Instead of changing the code, I suggest setting up a "translation" that turns the phrase "Personal Info" into "Contact Info".

This actually makes a ton of sense; I hadn't thought of that before! Do you have any pointers as to how I could go about setting up that "translation"?

As for the font, it displays in Courier New, or something similar - and it just looks bad in my opinion. So, I'm wanting to change the font family, say, to Arial. But that's also something I'm not too knowledgeable about, and fixing what the text actually said was more important, so I hadn't tried to delve too deep into that yet.

Link to comment
Share on other sites

12 minutes ago, agh151 said:

This actually makes a ton of sense; I hadn't thought of that before! Do you have any pointers as to how I could go about setting up that "translation"?

Not really. I don't actually know WordPress as well as it sounds like I do. Some Googling shows most people suggesting Loco Translate.

 

12 minutes ago, agh151 said:

As for the font, it displays in Courier New, or something similar - and it just looks bad in my opinion. So, I'm wanting to change the font family, say, to Arial. But that's also something I'm not too knowledgeable about, and fixing what the text actually said was more important, so I hadn't tried to delve too deep into that yet.

Well, first you'll have to find out exactly what that CSS is being applied to and where, then you can override it with your own CSS and/or theme.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.