Forum Replies Created

Viewing 8 replies - 16 through 23 (of 23 total)
  • Thread Starter Craig Griffiths

    (@craig-griffiths)

    It seems obvious when you say it. I am feeling a bit dumb. Thanks for the support. Is there a method of making these changes so they are upgrade proof. Just like the additional fields plugin.

    I am on an iPhone at the moment so I can’t check the code.

    Thanks again

    Thread Starter Craig Griffiths

    (@craig-griffiths)

    The plugin works fine. I can’t get the additional fields. Most importantly the “Licence to appear on the email.

    the Template and the Function php are in the link. I have included the lines I have added in the comment. The plugin is working.

    All I get on the email is ARRAY. I was hoping that rather than having to change the template and function PHP there may have been a way of putting some extra code in the plugin.

    Thanks

    I have gone to Cpanel and given full permission to everything and I still get this error as well.

    Thread Starter Craig Griffiths

    (@craig-griffiths)

    This is the code from your tutorial which I modified
    ——————————————–

    <?php
    /*
    Plugin Name: Custom Check Out
    Plugin URI:
    Description: This plugin contains the four custom fields of Telephone, Company, Licence Number and ACN
    Version:
    Author: Craig Griffiths
    Author URI:
    License:
    License URI:
    */
    
    // output our custom field HTML
    function pippin_edd_custom_checkout_fields() {
      ?>
    	<p id="edd-phone-wrap">
    		<label class="edd-label" for="edd-phone"><?php _e('Contact Number', 'pippin_edd'); ?></label>
    		<span class="edd-description"><?php _e( 'Enter your phone number so we can get in touch with you.', 'pippin_edd' ); ?></span>
    		<input class="edd-input" type="text" name="edd_phone" id="edd-phone" placeholder="<?php _e('Contact Number', 'pippin_edd'); ?>" value=""/>
    	</p>
    	<p id="edd-phone-wrap">
    		<label class="edd-label" for="edd-company"><?php _e('Company Name', 'pippin_edd'); ?></label>
    		<span class="edd-description"><?php _e( 'Enter the name of your company.', 'pippin_edd' ); ?></span>
    		<input class="edd-input" type="text" name="edd_company" id="edd-company" placeholder="<?php _e('Company Name', 'pippin_edd'); ?>" value=""/>
    	</p>
    
     <p id="edd-phone-wrap">
    		<label class="edd-label" for="edd-licence"><?php _e('Licence Number', 'pippin_edd'); ?></label>
    		<span class="edd-description"><?php _e( 'Enter your licence number.  So it can be attributed to your licence.', 'pippin_edd' ); ?></span>
    		<input class="edd-input" type="text" name="edd_licence" id="edd-licence" placeholder="<?php _e('licence Number', 'pippin_edd'); ?>" value=""/>
    	</p> 
    
       <p id="edd-phone-wrap">
    		<label class="edd-label" for="edd-ACN"><?php _e('ACN', 'pippin_edd'); ?></label>
    		<span class="edd-description"><?php _e( 'ACN that should appear on the tax invoice.', 'pippin_edd' ); ?></span>
    		<input class="edd-input" type="text" name="edd_ACN" id="edd-ACN" placeholder="<?php _e('ACN', 'pippin_edd'); ?>" value=""/>
    	</p> 
    
        <?php
    }
    add_action('edd_purchase_form_user_info', 'pippin_edd_custom_checkout_fields');
    
    // check for errors with out custom fields
    function pippin_edd_validate_custom_fields($valid_data, $data) {
    	if( empty( $data['edd_phone'] ) ) {
    		// check for a phone number
    		edd_set_error( 'invalid_phone', __('Please provide your phone number.', 'pippin_edd') );
    	}
    	if( empty( $data['edd_company'] ) ) {
    		// check for a phone number
    		edd_set_error( 'invalid_company', __('Please provide a company name.', 'pippin_edd') );
    	}
    
    if( empty( $data['edd_licence'] ) ) {
    		// check for a phone number
    		edd_set_error( 'invalid_licence', __('You must provide a licence number.', 'pippin_edd') );
    	}
    
    if( empty( $data['edd_ACN'] ) ) {
    		// check for a phone number
    		edd_set_error( 'invalid_ACN', __('An ACN is required so you can claim the GST.', 'pippin_edd') );
    	}
    
    }
    add_action('edd_checkout_error_checks', 'pippin_edd_validate_custom_fields', 10, 2);
    
    // store the custom field data in the payment meta
    function pippin_edd_store_custom_fields($payment_meta) {
    	$payment_meta['phone']   = isset( $_POST['edd_phone'] ) ? sanitize_text_field( $_POST['edd_phone'] ) : '';
    	$payment_meta['company'] = isset( $_POST['edd_company'] ) ? sanitize_text_field( $_POST['edd_company'] ) : '';
    	$payment_meta['licence'] = isset( $_POST['edd_licence'] ) ? sanitize_text_field( $_POST['edd_licence'] ) : '';
        $payment_meta['ACN'] = isset( $_POST['edd_ACN'] ) ? sanitize_text_field( $_POST['edd_ACN'] ) : '';
    
        return $payment_meta;
    }
    add_filter('edd_payment_meta', 'pippin_edd_store_custom_fields');
    
    // show the custom fields in the "View Order Details" popup
    function pippin_edd_purchase_details($payment_meta, $user_info) {
    	$phone   = isset( $payment_meta['phone'] ) ? $payment_meta['phone'] : 'none';
    	$company = isset( $payment_meta['company'] ) ? $payment_meta['company'] : 'none';
    	$licence = isset( $payment_meta['licence'] ) ? $payment_meta['licence'] : 'none';
        $ACN = isset( $payment_meta['ACN'] ) ? $payment_meta['ACN'] : 'none';
        ?>
    
    <li><?php echo __('Phone:', 'pippin_edd') . ' ' . $phone; ?></li>
    <li><?php echo __('Company:', 'pippin_edd') . ' ' . $company; ?></li>
    <li><?php echo __('Licence Number:', 'pippin_edd') . ' ' . $licence; ?></li>
    <li><?php echo __('ACN:', 'pippin_edd') . ' ' . $ACN; ?></li>
    	<?php
    }
    add_action('edd_payment_personal_details_list', 'pippin_edd_purchase_details', 10, 2);
    
    -------------------------------------------------------------------
    
    I have then added this to the Template.php. (I have added a few lines from around the line I have inserted so you know when it is placed in your code (approx line 74.)
    
    	$file_urls     = '';
    	$download_list = '
    <ul>';
    	$cart_items     = edd_get_payment_meta_cart_details( $payment_id );
        //next line is one I added trying to get the data from the payment meta.
    	$licence_data = edd_get_payment_meta_cart_details( $licence ['licence'] );
    	if ( $cart_items ) {
    		$show_names = apply_filters( 'edd_email_show_names', true );
    
    		foreach ( $cart_items as $item ) {
    
    			$price_id = edd_get_cart_item_price_id( $item );
    
    ---------------------------------------------------------
    
    I then added this following line so I could display it in the receipt (approx line 145)
    -----------------------------
    
    	$message = str_replace( '{receipt_id}', $receipt_id, $message );
    	$message = str_replace( '{payment_id}', $payment_id, $message );
    	//added the next line so I can get a shortcode for the email message.
    	$message = str_replace( '{licence}', $licence_data['licence'], $message );
    	$message = str_replace( '{receipt_link}', sprintf( __( '%1$sView it in your browser.%2$s', 'edd' ), '<a> $receipt_id, 'edd_action' => 'view_receipt' ), home_url() ) . '">', '</a>' ), $message );
    
    ------------------------------------------------------------
    
    And again at line 204
    ------------------------------------------------------------
    
    	$message = str_replace( '{product_notes}', $notes, $message );
    	$message = str_replace( '{payment_id}', $payment_id, $message );
    	// next line is for the licence number.
    	$message = str_replace( '{licence}', $licence_data['licence'], $message );
    	$message = str_replace( '{receipt_link}', sprintf( __( '%1$sView it in your browser.%2$s', 'edd' ), '<a> $receipt_id, 'edd_action' => 'view_receipt' ), home_url() ) . '">', '</a>' ), $message );
    
    ------------------------------------------------------------------
    
    In the FUNCTIONS.PHP I added the following around line 29
    ---------------------------------------------------------------
    
    function edd_email_purchase_receipt( $payment_id, $admin_notice = true ) {
    	global $edd_options;
    
    	$payment_data = edd_get_payment_meta( $payment_id );
    	// next line to try and get the data....
    	$licence_data = edd_get_payment_meta( $licence );
    	$user_info    = maybe_unserialize( $payment_data['user_info'] );
    	$email        = edd_get_payment_user_email( $payment_id );
    
    ------------------------------------------------------------
    
    at line 43
    --------------
    
    	$message .= edd_get_email_body_content( $payment_id, $payment_data, $licence_data );
    
    ------------------------------

    [Please, please use the code buttons – as is, this code may have been corrupted by the forum parsers.]

    I have uploaded the two files to Google Drive here is the link. THANKS SO MUCH.

    https://drive.google.com/folderview?id=0B8OR7wQit3ZiMlZXSjhRaFZxeXM&usp=sharing

    Thread Starter Craig Griffiths

    (@craig-griffiths)

    I understand you are working on the problem as well. I was hoping to solve it and save you some time.

    I have created the custom plugin as you suggested.

    I have made changes to the code. It is almost working. I am getting the word “Array” appearing in the email. So I am not getting the data from the payment meta.

    Can I post the code somewhere?

    Thread Starter Craig Griffiths

    (@craig-griffiths)

    Is there any notes or docs on adding custom fields to the receipt?

    Thanks

    Thread Starter Craig Griffiths

    (@craig-griffiths)

    I found a fix.

    I added:
    define(‘WP_MEMORY_LIMIT’, ’64M’);

    to my wp-config.php file

    Thread Starter Craig Griffiths

    (@craig-griffiths)

    No I don’t have those memory issues. This is my php.ini
    memory_limit = 128M;
    upload_max_filesize = 8M;

    Not sure why I am getting them.

    I don’t have a lot of plugins installed. This plugin, Easy Digital Downloads and yeast (SEO).

    Not sure why this is happening.

Viewing 8 replies - 16 through 23 (of 23 total)