Plugin Directory

Changeset 3337338


Ignore:
Timestamp:
07/31/2025 02:15:36 PM (7 months ago)
Author:
neebplugins
Message:

Release 4.2.5

Location:
wc-thanks-redirect
Files:
278 added
3 edited

Legend:

Unmodified
Added
Removed
  • wc-thanks-redirect/trunk/readme.txt

    r3334040 r3337338  
    77Requires at least: 6.2
    88Tested up to: 6.8
    9 Stable tag: 4.2.4
    10 Version: 4.2.4
     9Stable tag: 4.2.5
     10Version: 4.2.5
    1111Requires PHP: 7.4
    1212License: GPLv2 or later
     
    636312- Compatible with <a target="_blank" href="https://wordpress.org/plugins/approve-orders/">Approve Orders for WooCommerce</a>, enabling **Order Approval** allowing shop owners to **approve** or **reject** orders before payment is processed.
    6464
     6513- GTM DataLayer for Google Analytics
     66
     6714- FBQ Track Purchase
     68
    6569
    6670**PRO Features**
     
    8185In the “Thank You URL” field in the product? put like this https://site.com/thanks?client_email=[billing_email]
    8286
    83 8- eCommerce DataLayer for Analytics
    84 
    85 9- Thank you page based on Payment Gateway
    86 
    87 10- Thank You Page based on User Role
    88 
    89 11- Thank you page based on Product Type
    90 
    91 12- Thank You Page based on Product Category
    92 
    93 13- Thank You Page based on Product Tags
    94 
    95 14- Thank You Page based on Product Variation
    96 
    97 15- Thank You Page Rules allow you to easily create customized Thank You pages with advanced logic from the user interface—no coding needed! Tailor your pages to meet your specific needs effortlessly.
    98 
    99 16- WooCommerce Checkout Manager compatibility
    100 
    101 17 - **Optionally, you can choose between a classic or modern template for order details:**
     878- Thank you page based on Payment Gateway
     88
     899- Thank You Page based on User Role
     90
     9110- Thank you page based on Product Type
     92
     9311- Thank You Page based on Product Category
     94
     9512- Thank You Page based on Product Tags
     96
     9713- Thank You Page based on Product Variation
     98
     9914- Thank You Page Rules allow you to easily create customized Thank You pages with advanced logic from the user interface—no coding needed! Tailor your pages to meet your specific needs effortlessly.
     100
     10115- WooCommerce Checkout Manager compatibility
     102
     10316 - **Optionally, you can choose between a classic or modern template for order details:**
    102104* For the classic template (default), use: **[TRFW_ORDER_DETAILS template="classic"]**
    103105* For the modern template, use: **[TRFW_ORDER_DETAILS template="modern"]**
     
    192194== Changelog ==
    193195
     196**V 4.2.5**
     197GTM Datalayer.
     198FBQ Track Purchase
     199
    194200**V 4.2.4**
    195201Various fixes.
     
    275281== Upgrade Notice ==
    276282
    277 = 4.2.3 =
    278 AJAX Fix
     283= 4.2.5 =
     284eCommerce Tracking
  • wc-thanks-redirect/trunk/src/Front.php

    r3195464 r3337338  
    3333        /* Redirect to thank you */
    3434        add_action( 'woocommerce_thankyou', array( $this, 'safe_redirect' ), 99, 1 );
    35     }
    36 
     35        /* Add action for Footer */
     36        add_action( 'wp_footer', array( $this, 'datalayer_purchase_event' ) );
     37    }
     38
     39    /**
     40     * Shortcode Order Details
     41     *
     42     * @since 4.2.0
     43     * @return string
     44     */
    3745    public function shortcode_order_details() {
    3846
     
    166174    }
    167175
     176    /**
     177     * Safe Redirect.
     178     *
     179     * @since 4.2.0
     180     * @param WC_Order $order_id
     181     * @return void
     182     */
    168183    public function safe_redirect( $order_id ) {
    169184        $wctr_global = get_option( 'wctr_global' );
     
    240255        }
    241256    }
     257
     258    /**
     259     * Datalayer purchase event.
     260     *
     261     * @since 4.2.5
     262     * @param array $atts Array of attributes.
     263     */
     264    public function datalayer_purchase_event( $atts = array() ) { // phpcs:ignore
     265
     266        // Check if order received ID exists in the query var
     267        $order_id = wc_thanks_redirect_get_order_id();
     268        if ( ! $order_id ) {
     269            return;
     270        }
     271
     272        $order = wc_get_order( $order_id );
     273        if ( ! $order ) {
     274            return;
     275        }
     276
     277        // Fetch order data
     278        $order_items    = $order->get_items();
     279        $items_data     = array();
     280        $fb_content_ids = array();
     281        $fb_contents    = array();
     282
     283        foreach ( $order_items as $item_id => $item ) { // phpcs:ignore
     284            $product      = $item->get_product();
     285            $item_data    = array(
     286                'item_name'     => $item->get_name(),
     287                'item_id'       => $product->get_sku() ? $product->get_sku() : $product->get_id(),
     288                'price'         => $product->get_price(),
     289                'item_brand'    => $this->get_product_brand( $product->get_id() ),
     290                'item_category' => $product ? wc_get_product_category_list( $product->get_id(), ', ' ) : '',
     291                'quantity'      => $item->get_quantity(),
     292            );
     293            $items_data[] = $item_data;
     294
     295            // Data for Facebook Pixel
     296            $fb_content_ids[] = $product->get_sku() ? $product->get_sku() : (string) $product->get_id();
     297            $fb_contents[]    = array(
     298                'id'       => $product->get_sku() ? $product->get_sku() : (string) $product->get_id(),
     299                'quantity' => $item->get_quantity(),
     300            );
     301        }
     302
     303        // DataLayer variables
     304        $currency       = get_woocommerce_currency();
     305        $value          = $order->get_total();
     306        $tax            = $order->get_total_tax();
     307        $shipping       = $order->get_shipping_total();
     308        $affiliation    = get_bloginfo( 'name' );
     309        $transaction_id = $order->get_order_number();
     310        $coupon_code    = $order->get_coupon_codes() ? implode( ',', $order->get_coupon_codes() ) : '';
     311
     312        // Prepare the JavaScript dataLayer and Facebook Pixel script
     313        ?>
     314        <script>
     315            // DataLayer for GTM
     316            window.dataLayer = window.dataLayer || [];
     317            window.dataLayer.push({
     318                event: 'purchase',
     319                ecommerce: {
     320                    currency: '<?php echo esc_js( $currency ); ?>',
     321                    value: <?php echo esc_js( $value ); ?>,
     322                    tax: <?php echo esc_js( $tax ); ?>,
     323                    shipping: <?php echo esc_js( $shipping ); ?>,
     324                    affiliation: '<?php echo esc_js( $affiliation ); ?>',
     325                    transaction_id: '<?php echo esc_js( $transaction_id ); ?>',
     326                    coupon: '<?php echo esc_js( $coupon_code ); ?>',
     327                    items: <?php echo wp_json_encode( $items_data ); ?>
     328                }
     329            });
     330
     331            // Facebook Pixel Purchase Event
     332            // Ensure the fbq function is loaded before calling it
     333            if (typeof fbq === 'function') {
     334                fbq('track', 'Purchase', {
     335                    value: <?php echo esc_js( $value ); ?>,
     336                    currency: '<?php echo esc_js( $currency ); ?>',
     337                    content_type: 'product',
     338                    contents: <?php echo wp_json_encode( $fb_contents ); ?>
     339                });
     340            }
     341        </script>
     342        <?php
     343    }
     344
     345    /**
     346     * Get Product Brand.
     347     *
     348     * @since 4.2.5
     349     * @param WC_Product $product_id
     350     */
     351    public function get_product_brand( $product_id ) {
     352
     353        $brand = '';
     354
     355        if ( ! empty( $product_id ) ) {
     356            $brand_terms = get_the_terms( $product_id, 'product_brand' );
     357
     358            if ( ! empty( $brand_terms ) && ! is_wp_error( $brand_terms ) ) {
     359                $brand = $brand_terms[0]->name; // Use the first brand term.
     360            }
     361        }
     362
     363        return $brand;
     364    }
    242365}
  • wc-thanks-redirect/trunk/wc-thanks-redirect.php

    r3334040 r3337338  
    1111 * Plugin URI:        https://nitin247.com/plugin/wc-thanks-redirect/
    1212 * Description:       Thank You Page for WooCommerce allows adding Thank You Page or Thank You URL for WooCommerce Products for your Customers, now supports Order Details on Thank You Page. This plugin does not support Multisite.
    13  * Version:           4.2.4
     13 * Version:           4.2.5
    1414 * Author:            Nitin Prakash
    1515 * Author URI:        http://www.nitin247.com/
     
    3131defined( 'ABSPATH' ) || die( 'WordPress Error! Opening plugin file directly' );
    3232
    33 defined( 'WCTR_VERSION' ) || define( 'WCTR_VERSION', '4.2.4' );
     33defined( 'WCTR_VERSION' ) || define( 'WCTR_VERSION', '4.2.5' );
    3434defined( 'WCTR_DIR' ) || define( 'WCTR_DIR', plugin_dir_path( __DIR__ ) );
    3535defined( 'WCTR_FILE' ) || define( 'WCTR_FILE', __FILE__ );
     
    181181/* Get Order ID from request */
    182182function wc_thanks_redirect_get_order_id() {
    183     global $wp;
    184183
    185184    $order_id = 0;
     
    192191        $order_id  = wc_get_order_id_by_order_key( $order_key );
    193192    } else {
    194         $current_url = home_url( add_query_arg( array(), $wp->request ) );
    195         $parsed_url  = wp_parse_url( $current_url );
    196         $order_id    = array_pop( explode( '/', $parsed_url['path'] ) );
     193        $order_id = 0;
    197194    }
    198195
Note: See TracChangeset for help on using the changeset viewer.