Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter januszu

    (@januszu)

    unfortunetly :
    remove_action( ‘woocommerce_after_shop_loop_item’, ‘woocommerce_template_loop_add_to_cart’, 10 );

    is deleting also “add to card” from products page.
    And i want to leave it there. Is there any different path?

    Thread Starter januszu

    (@januszu)

    ok I understand, I thought that it can be something easy – like few lines. Thank you for your advice Mike 🙂 Have a nice day 🙂

    Thread Starter januszu

    (@januszu)

    Thanks for your response Mike.
    Sorry I forgot to add the most importatnt thing – I don’t know php.

    But i understand that after I made this field in form-coupon.php i have to add something to functions.php and that lets me see text from this custom field in my order email. The question is what i have to add there? What code?

    I ve already added one code (from forum) to functions.php to see coupon code in my order email.

    add_action( 'woocommerce_email_after_order_table', 'add_payment_method_to_admin_new_order', 15, 2 );
    
    /**
     * Add used coupons to the order confirmation email
     *
    */
    function add_payment_method_to_admin_new_order( $order, $is_admin_email ) {
    
    	if ( $is_admin_email ) {
    
    		if( $order->get_used_coupons() ) {
    
    			$coupons_count = count( $order->get_used_coupons() );
    
    		    $i = 1;
    		    $coupons_list = '';
    
    		    foreach( $order->get_used_coupons() as $coupon) {
    		        $coupons_list .=  $coupon;
    		        if( $i < $coupons_count )
    		        	$coupons_list .= ', ';
    		        $i++;
    		    }
    
    		    echo '<p><strong>Rabat (' . $coupons_count . ') :</strong> ' . $coupons_list . '</p>';
    
    		} // endif get_used_coupons
    
    	} // endif $is_admin_email
    }
    
    add_action( 'woocommerce_admin_order_data_after_billing_address', 'custom_checkout_field_display_admin_order_meta', 10, 1 );
    
    /**
     * Add used coupons to the order edit page
     *
    */
    function custom_checkout_field_display_admin_order_meta($order){
    
        if( $order->get_used_coupons() ) {
    
        	$coupons_count = count( $order->get_used_coupons() );
    
            $i = 1;
    
            foreach( $order->get_used_coupons() as $coupon) {
    	        echo $coupon;
    	        if( $i < $coupons_count )
    	        	echo ', ';
    	        $i++;
            }
    
            echo '</p>';
        }
    
    }

    I thought that there’s some similar way to add my custom field to email order. I tried by my self, but everything i’ ve got was an error.

    And that’s all what is in my form-coupon.php :

    <?php
    /**
     * Checkout coupon form
     *
     * This template can be overridden by copying it to yourtheme/woocommerce/checkout/form-coupon.php.
     *
     * HOWEVER, on occasion WooCommerce will need to update template files and you (the theme developer).
     * will need to copy the new files to your theme to maintain compatibility. We try to do this.
     * as little as possible, but it does happen. When this occurs the version of the template file will.
     * be bumped and the readme will list any important changes.
     *
     * @see     http://docs.woothemes.com/document/template-structure/
     * @author  WooThemes
     * @package WooCommerce/Templates
     * @version 2.2
     */
    
    if ( ! defined( 'ABSPATH' ) ) {
    	exit; // Exit if accessed directly
    }
    
    if ( ! wc_coupons_enabled() ) {
    	return;
    }
    
    if ( ! WC()->cart->applied_coupons ) {
        $info_message = apply_filters( 'woocommerce_checkout_coupon_message', __( 'Masz konto Fitline?', 'woocommerce' ) . ' <a href="#" class="showcoupon">' . __( 'Wpisz swój numer Fitline i aktywuj zniżkę', 'woocommerce' ) . '</a>' );
        wc_print_notice( $info_message, 'notice' );
    }
    ?>
    
    <form class="checkout_coupon" method="post" style="display:none">
    
        <header><h3><?php _e( 'Zniżka', 'woocommerce' ); ?></h3></header>
    
    	<p class="form-row form-row-wide">
    		<input type="text" name="billing_numer_tp" class="input-text" placeholder="<?php esc_attr_e( 'Numer TP', 'woocommerce' ); ?>" id="numer_tp" value="" />
    	</p>
    
        <p class="form-row form-row-first">
    		<input type="text" name="coupon_code" class="input-text" placeholder="<?php esc_attr_e( 'Procent zniżki', 'woocommerce' ); ?>" id="coupon_code" value="" />
    	</p>
    
    	<p class="form-row form-row-last">
    		<input type="submit" class="button" name="apply_coupon" value="<?php esc_attr_e( 'Aktywuj zniżkę', 'woocommerce' ); ?>" />
    	</p>
    
    	<div class="clear"></div>
    </form>

    So i don’t know if i understand you well, but i didn’t add anything more than this code in form-coupon.php:

    <form class="checkout_coupon" method="post" style="display:none">
    
        <header><h3><?php _e( 'Zniżka', 'woocommerce' ); ?></h3></header>
    
    	<p class="form-row form-row-wide">
    		<input type="text" name="billing_numer_tp" class="input-text" placeholder="<?php esc_attr_e( 'Numer TP', 'woocommerce' ); ?>" id="numer_tp" value="" />
    	</p>

    and i don’t even know is this correct

Viewing 3 replies - 1 through 3 (of 3 total)