Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Subrata Mal

    (@subratamal)

    @roberto22 Please use the attached code in the theme functions.php file to display the cashback amount on the order details page.

    add_action('woocommerce_order_details_after_order_table', 'woocommerce_order_details_after_order_table_callback', 2);
    
    if(!function_exists('woocommerce_order_details_after_order_table_callback')){
        function woocommerce_order_details_after_order_table_callback($order){
            $cashback_amount = get_total_order_cashback_amount( $order->get_id() );
            if($cashback_amount) :
                ?>
                <table>
                    <tbody>
                        <tr>
                            <td>Cashback </td>
                            <td><?php echo wc_price($cashback_amount); ?></td>
                        </tr>
                    </tbody>
                </table>
                <?php
            endif;
        }
    }
    Thread Starter roberto22

    (@roberto22)

    Hi,

    Can you please help me identify the correct css class for the cashback amount to me align to the right? I have tried but i cant figure it out yet.

    https://prnt.sc/Nx9VVUGO2Z_g

    Thanks for the help!

    Plugin Author Subrata Mal

    (@subratamal)

    @roberto22 Please use attached updated code.

    add_action('woocommerce_order_details_after_order_table', 'woocommerce_order_details_after_order_table_callback', 2);
    
    if(!function_exists('woocommerce_order_details_after_order_table_callback')){
        function woocommerce_order_details_after_order_table_callback($order){
            $cashback_amount = get_total_order_cashback_amount( $order->get_id() );
            if($cashback_amount) :
                ?>
                <table>
                    <tbody>
                        <tr>
                            <td class="cashback_lable">Cashback </td>
                            <td class="cashback_amount"><?php echo wc_price($cashback_amount); ?></td>
                        </tr>
                    </tbody>
                </table>
                <?php
            endif;
        }
    }

    then you can use cashback_amount to apply custom CSS.

    Thread Starter roberto22

    (@roberto22)

    Hi,

    Thanks it worked!

    As i have in the settings that the cashback is only credited when order is completed, the cashback amount isnt showing until i change the status to completed.

    Is possible to show the amount regardless of the order status. So the user can see and know the cashback his earning once the order is completed.

    Thank you for your time.

    Plugin Author Subrata Mal

    (@subratamal)

    @roberto22 Please use the attached updated code.

    add_action('woocommerce_order_details_after_order_table', 'woocommerce_order_details_after_order_table_callback', 2);
    
    if(!function_exists('woocommerce_order_details_after_order_table_callback')){
        function woocommerce_order_details_after_order_table_callback($order){
            $cashback_amount = woo_wallet()->cashback->calculate_cashback(false, $order->get_id()); //get_total_order_cashback_amount( $order->get_id() );
            if($cashback_amount) :
                ?>
                <table>
                    <tbody>
                        <tr>
                            <td class="cashback_lable">Cashback </td>
                            <td class="cashback_amount"><?php echo wc_price($cashback_amount); ?></td>
                        </tr>
                    </tbody>
                </table>
                <?php
            endif;
        }
    }
    Thread Starter roberto22

    (@roberto22)

    Thanks a lot.

    And Can i show here in the list of orders? https://prnt.sc/9eigP5vtOTQF

    Sorry to bother you so much with this.

    Plugin Author Subrata Mal

    (@subratamal)

    @roberto22 Please use the attached for this.

    add_filter('woocommerce_my_account_my_orders_columns', 'woocommerce_my_account_my_orders_columns_callback', 10, 1);
    if(!function_exists('woocommerce_my_account_my_orders_columns_callback')) {
        function woocommerce_my_account_my_orders_columns_callback($columns) {
            $order_actions = $columns['order-actions'];
            unset($columns['order-actions']);
            $columns['cashback'] = __('Cashback');
            $columns['order-actions'] = $order_actions;
            return $columns;
        }
    }
    
    add_action('woocommerce_my_account_my_orders_column_cashback', 'woocommerce_my_account_my_orders_column_cashback_callback', 10, 1);
    if(!function_exists('woocommerce_my_account_my_orders_column_cashback_callback')) {
        function woocommerce_my_account_my_orders_column_cashback_callback($order) {
            $cashback_amount = woo_wallet()->cashback->calculate_cashback(false, $order->get_id());
            echo wc_price($cashback_amount);
        }
    }
    Thread Starter roberto22

    (@roberto22)

    Thank you! ??

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Cashback amount in order detal page’ is closed to new replies.