• Hi, i’m using this plugin. It’s awesome :D.
    I had need to edit some code for my site, but i can’t update this plugin without edits, now.
    Can you implement standard wordpress template system? I will able to make overrides of plugin.

    Thank you.
    I’m software developer, I can help you with this edit if it is necessary ??

    Thank you,
    Mariano

Viewing 6 replies - 1 through 6 (of 6 total)
  • @il_maca,

    I’m not sure I understand what you are referring to, so please send along some code. I assume you mean woocommerce cart & checkout templates. If you need hooks added, please specify where and which arguments you might need. Thank you

    Thread Starter Il_maca

    (@il_maca)

    apologize sir, my english isn’t pretty good.

    So, you can see:
    https://salferrarello.com/overridable-templates-wordpress-plugin/

    Thank you

    Thread Starter Il_maca

    (@il_maca)

    Just an example:

    Added new function in woocommerce-grift-wrapper.php (for test only):

    public function add_gift_wrap_after_coupon_test() {
    		$coupons_var = $this;
    		// Set our template to be the override template in the theme.
    		$tmpl = get_stylesheet_directory() . '/woocommerce-gift-wrapper/gift_wrap_after_coupon.php';
    
    		if ( ! file_exists( $tmpl ) ) {
    			// If the override template does NOT exist, fallback to the default template.
    			$tmpl = __DIR__ . '/templates/gift_wrap_after_coupon.php';		}
    
    		// Display the template.
    		include $tmpl;
    	}

    Edited add_action, to call new function:
    add_action( 'woocommerce_cart_coupon', array( $this, 'add_gift_wrap_after_coupon_test' ) );

    So, i created gift_wrap_after_coupon.php file in woocommerce-gift-wrapper/templates/:

    
    <?php
    /**
     * Default: Template for Gift Wrap After coupon.
     *
     * Note:
     *
     * @var $coupons_var
     *
     * @package woocommerce-gift-wrapper
     */
    
    ?>
    
    <?php
    if ( count( $coupons_var->get_giftwrapped_products() ) > 0 ) {
    ?>
    			<tr>
    				<td colspan="6" class="actions">
    					<div class="giftwrap" style="cursor:pointer;font-family:'Montserrat',sans-serif;padding:15px 0px;">
    						<div style="display:inline-block;">
    							<i class="ecommerce-gift" style="padding: 0 0 0 22px;width:68px;font-size:29px;display:inline-block;float:left;color:#EC7A5C;"></i>
    							<span><?php _e( 'Vuoi regalarlo a qualcuno?', 'woocommerce-gift-wrapper' ); ?></span>
    						</div>
    						
    						<a href="#" class="show_giftwrap" style="float:right;font-size:0.8125rem!important;">
    <?php
    							if ( get_option( 'giftwrap_header' ) == 'Add gift wrapping?' || get_option( 'giftwrap_header' ) === false ) {
    								_e( 'CLICCA PER LA CONFEZIONE REGALO', 'woocommerce-gift-wrapper' );
    								//_e( 'Add gift wrapping?', 'woocommerce-gift-wrapper' );
    							} else { // pre version 2.0
    								echo esc_html( get_option( 'giftwrap_header' ) );
    							}
    ?>
    						</a>
    					</div>
    
    					<div id="wc-giftwrap" class="wc-giftwrap giftwrap-coupon" style="display:none;padding:18px;background:rgba(84,84,84,0.05);">
    <?php 
    						if ( $coupons_var->giftwrap_modal == 'yes' ) { // if modal version
    							$coupons_var->display_giftwrap_modal( $label = "_coupon" );
    						} else if ( $coupons_var->giftwrap_modal == 'no' ) { // non-modal version
    ?>
    							<?php/*<div class="giftwrap_header_wrapper">
    								<h3 class="giftwrap_header">
    <?php 
    									if ( get_option( 'giftwrap_header' ) == 'Add gift wrapping?' || get_option( 'giftwrap_header' ) === false ) {
    										_e( 'Add gift wrapping?', 'woocommerce-gift-wrapper' );
    									} else { // pre version 2.0
    										echo esc_html( get_option( 'giftwrap_header' ) );
    									}
    ?>
    								</h3>
    							</div>*/?>
    <?php
    							if ( $coupons_var->current_theme_name == 'Avada' ) echo "<form method='post' class='giftwrap_products'>";
    
    							if ( $coupons_var->giftwrap_details != '' ) echo "<p class='giftwrap_details'>" . $coupons_var->giftwrap_details . "</p>";
    			
    							$coupons_var->giftwrap_list( $label = "coupon_" );
    ?>		   
    							<button type="submit" id="coupon_giftwrap_submit" class="button btn alt giftwrap_submit fusion-button fusion-button-default" name="giftwrap_btn" style="clear:both;">
    <?php
    								if ( get_option( 'giftwrap_button' ) == 'Add Gift Wrap to Order' || get_option( 'giftwrap_button' ) === false ) {
    									_e( 'Add Gift Wrap to Order', 'woocommerce-gift-wrapper' );
    								} else { // pre version 2.0
    									echo get_option( 'giftwrap_button' );
    								}
    ?>
    							</button>
    <?php
    							if ( $coupons_var->current_theme_name == 'Avada' ) echo "</form>";
    						}
    
    						
    ?>
    						<script type="text/javascript">
    							/* <![CDATA[ */	
    <?php
    							$giftwrap_in_cart = $coupons_var->is_gift_wrap_in_cart();
    							// if replacing the only giftwrap item allowed in cart
    							if ( $giftwrap_in_cart === true && $coupons_var->giftwrap_number == 'no' ) {
    ?>
    								jQuery('.coupon .giftwrap_submit').click( function() {
    									if ( window.confirm( "<?php _e( 'Are you sure you want to replace the gift wrap in your cart?', 'woocommerce-gift-wrapper' ); ?>" ) ) return true;
    									return false;
    								});
    <?php
    							}
    ?>							
    							jQuery( function( $ ) {
    								var wc_checkout_giftwrap = {
    									init: function() {
    										$( document.body ).on( 'click', '.giftwrap', this.show_giftwrap_form );
    										$( '#wc-giftwrap' ).hide();
    									},
    									show_giftwrap_form: function() {
    										$( '#wc-giftwrap' ).slideToggle( 400 );
    										return false;
    									}
    								};
    								wc_checkout_giftwrap.init();
    							});
    							/* ]]> */
    						</script>
    						<noscript></noscript>
    						<style>
    							.giftwrap::before{
    								font-family: typicons;
    							}
    						</style>
    					</div><!-- /.wc-giftwrap -->		
    				</td>
    			</tr>
    <?php
    		}
    ?>

    I can override this file in my theme now. With future updates, i will not worry about changes in plugin… I only should update my override files if it is necessary !

    • This reply was modified 7 years, 3 months ago by Il_maca.
    • This reply was modified 7 years, 3 months ago by Il_maca.
    • This reply was modified 7 years, 3 months ago by Il_maca.

    Thank you @il_maca, this seems like a pretty darn good idea. It could solve some issues with cross-theme compatibility, but could also cause some troubles, so I’ll have to look more into it!

    Thread Starter Il_maca

    (@il_maca)

    Great!

    Thank you @littlepackage,
    have a nice day ??

    Hi again @il_maca,

    First of all, thank you kindly for leaving a review – I appreciate your time. I took a few minutes to look at your request and understand it more; however, being realistic with myself, I just don’t have time to invest right now, especially with very little request for such an adjustment (yours). If you would like to code this out, I will definitely review it and put it in core — IF it doesn’t risk putting other people out (that was one of my main concerns). In other words, at this time, if you want it, you’re going to need to build it. Thank you for understanding!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Template system’ is closed to new replies.