Overwrite templates

This topic contains 10 replies, has 4 voices, and was last updated by  Kiran 4 years, 8 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket

Tagged: 

  • Author
    Posts
  • #4361

    Samantha
    Free User
    Post count: 33

    Hey there. I need to make a few modifications to these files:

    wpinv-invoice-receipt.php
    emails/wpinv-email-invoice-details.php
    includes/wpinv-template-functions.php

    I can’t seem to figure out the structure I need to use to place these files in my child theme and overwrite.

    Can you please advise?

    Thanks!

    #4364

    Alex Rollin
    Moderator
    Post count: 27815

    The developers are looking into this, thanks for your patience.

    #4365

    Kiran
    Moderator
    Post count: 7069

    Hello Misty,

    – Copy file wpinv-invoice-receipt.php from /plugins/invoicing/templates/ into /themes/YOUR-CURRENT-THEME/invoicing/
    – Copy file wpinv-email-invoice-details.php from /plugins/invoicing/templates/emails/ into /themes/YOUR-CURRENT-THEME/invoicing/emails/

    You can edit files copied under /themes/YOUR-CURRENT-THEME/invoicing/.

    – includes/wpinv-template-functions.php is a plugin core file and core files should not be modified otherwise it may break core functionality. Instead you can use hooks to add customization.
    Let us know what you need to change via includes/wpinv-template-functions.php file so we can help you to add your customization.

    Thanks,
    Kiran

    #4368

    Samantha
    Free User
    Post count: 33

    Yes, that works perfectly thank you!

    On the functions file I just need to change the wording on the button. It says “Proceed to pay” and I need to change it to just “Proceed”.

    We use offline payment so it’s a bit misleading to have it say “proceed to pay” when they’re not actually paying.

    #4369

    Samantha
    Free User
    Post count: 33

    Another question for wpinv-invoice-receipt.php. Is it possible in this to pull in the product_type (CPT) and display a different message depending on the CPT?

    #4372

    Guust
    Moderator
    Post count: 29970

    The best and simplest way to change wording is using the language files.
    https://wpinvoicing.com/docs/translation/translate-main-plugin/

    I’ll leave the last question for Kiran.

    Thanks

    #4373

    Kiran
    Moderator
    Post count: 7069

    Hi Misty,

    On the functions file I just need to change the wording on the button. It says “Proceed to pay” and I need to change it to just “Proceed”.

    You can change checkout button label via translation that @guust suggested or you can do it by using following PHP snippet.

    
    
    /**
     * Change checkout button label.
     */
    function wpi_snippet_200319_checkout_button_purchase( $button ) {
    	$search = 'Proceed to Pay'; // Current button label
    	$replace = 'Proceed';       // New button label
    
    	$button = str_replace( __( $search, 'invoicing' ), __( $replace, 'invoicing' ), $button );
    
    	return $button;
    }
    add_filter( 'wpinv_checkout_button_purchase', 'wpi_snippet_200319_checkout_button_purchase', 20, 1 );

    ===

    Another question for wpinv-invoice-receipt.php. Is it possible in this to pull in the product_type (CPT) and display a different message depending on the CPT?

    Can you clarify with example that how you want so i can help in this?

    Thanks,
    Kiran

    #4376

    Samantha
    Free User
    Post count: 33

    Thanks Kiran, you rock! I’d much prefer to use the php snippet.

    I basically need to do similar to what this snippet did but on the invoice confirmation:
    https://wpgeodirectory.com/support/topic/customizing-confirmation-messages/

    I need to replace the _e in this line:

     <div class="wpinv-receipt-message"><?php _e( 'Thank you!', 'invoicing' ); ?></div> 

    depending on the CPT. something like:

    
    if CPT = gd_apartments
        return "Thank you! Your apartment will be reviewed and you will receive an email when it's approved. You may now add floorplans to your apartment. Add Floorplans "
    
    if CPT = gd_business
        return "Thank you! Your business will be reviewed and you will receive an email when it's approved."
    
    if CPT = gd_product
       return "Thank you! Your product will be reviewed and you will receive an email when it's approved."
    
    #4377

    Samantha
    Free User
    Post count: 33
    This reply has been marked as private.
    #4384

    Kiran
    Moderator
    Post count: 7069
    
    
    	<?php
    	$post_type = '';
    
    	foreach ( $cart_items as $key => $cart_item ) {
    		if ( ! empty( $cart_item['id'] ) && wpinv_get_item_type( $cart_item['id'] ) == 'package' && ( $package_id = get_post_meta( $cart_item['id'], '_wpinv_custom_id', true ) ) ) {
    			$post_type = geodir_pricing_package_post_type( $package_id );
    
    			if ( $post_type ) {
    				break;
    			}
    		}
    	}
    	
    	if ( $post_type == 'gd_apartments' ) {
    		$message = __( 'Thank you!', 'invoicing' ); // Message for gd_apartments
    	} elseif ( $post_type == 'gd_business' ) {
    		$message = __( 'Thank you!', 'invoicing' ); // Message for gd_business
    	} else {
    		$message = __( 'Thank you!', 'invoicing' ); // Message for other
    	}
    	?>
    	<div class="wpinv-receipt-message"><?php echo $message; ?></div>
    #4385

    Kiran
    Moderator
    Post count: 7069

    Hi Misty,

    Try replacing

    <div class="wpinv-receipt-message"><?php _e( 'Thank you!', 'invoicing' ); ?></div>

    with https://wpinvoicing.com/support/topic/overwrite-templates/#post-4384 script in file /themes/YOUR-CURRENT-THEME/invoicing/wpinv-invoice-receipt.php

    Kiran

Viewing 11 posts - 1 through 11 (of 11 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket