Plugin Directory

Changeset 2721057


Ignore:
Timestamp:
05/10/2022 08:26:17 AM (4 years ago)
Author:
relevanz
Message:

2.1.1

Location:
releva-nz/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • releva-nz/trunk/README.txt

    r2669900 r2721057  
    33Tags: e-commerce, sales, advertising, marketing, retargeting, remarketing
    44Requires at least: 3.0.1
    5 Tested up to: 5.9.0
     5Tested up to: 6.0.0
    66Requires PHP: 5.2
    77Stable tag: trunk
     
    5959* update WooCommerce function calls which are deprecated and gonna be removed in the future
    6060* adjust conversion tracking to exclude tax and shipping cost
     61
     62= 2.1.1 =
     63* improved multisite support
     64* improve conversion tracking
     65* support for Wordpress 6
  • releva-nz/trunk/includes/class-relevatracking.php

    r2369532 r2721057  
    7070
    7171        $this->plugin_name = 'relevatracking';
    72         $this->version = '1.0.0';
     72        $this->version = '2.1.1';
    7373
    7474        $this->load_dependencies();
  • releva-nz/trunk/public/class-relevatracking-public.php

    r2628019 r2721057  
    5555        //$this->load_client_id();
    5656        $this->client_id = self::load_client_id();
    57         // http://localhost/patricianic.domain.wp/?releva_action=jsonexport (json export product)
    58         add_action( 'releva_jsonexport', array( $this, 'jsonexport' ) );
     57
    5958        add_action( 'releva_csvexport', array( $this, 'csvexport' ) );
    6059        add_action( 'releva_callback', array( $this, 'callback' ) );
     
    204203    }
    205204
    206     // http://localhost/patricianic.domain.wp/?releva_action=jsonexport (json export product)
    207     public function jsonexport() {
    208                $args = array(
    209                     //'posts_per_page' => 10000,
    210                     //'product_cat' => 'category-slug-here',
    211                     //'post_type' => 'product',
    212                     //'post_status'   => array('publish'),
    213                     'fields'        => 'ids',
    214                     'posts_per_page'=> -1,
    215                     'post_type'     => array('product'),
    216                     'orderby' => 'title',
    217                 );
    218 
    219                 $the_query = new WP_Query( $args );
    220                 // The Loop
    221                 $full_data = array();
    222                 global $wpdb;
    223 
    224                 if( $the_query->have_posts() )
    225                 {
    226                     //while ( $the_query->have_posts() ) {
    227                     //$the_query->the_post();
    228                     foreach ($the_query->posts as $product_id) {
    229 
    230                         //$the_query->post->ID = $product_id
    231 
    232                         $single_product = array();
    233                         $product = get_product($product_id);
    234                         if(empty($product) ) {
    235                             continue;
    236                         }
    237                         $single_product['product_id'] = $product_id;
    238                         //$single_product['product_id'] = $product->get_id();
    239 
    240                         $post_categories = wp_get_post_terms($product_id, $taxonomy = 'product_cat');
    241                         $cat = ''; $ii = 0;
    242                         foreach((array)$post_categories as $post_category):
    243                             if($ii > 0){$cat .= ',';}
    244                             //$cat .= $post_category->name;
    245                             $cat .= $post_category->term_id;
    246                             $ii++;
    247                         endforeach;
    248                         $single_product['category_ids'] = $cat;
    249                         $single_product['product_name'] = $product->post->post_title;
    250                         $single_product['short_description'] = $product->post->post_excerpt;
    251                         $single_product['price'] = get_post_meta($product_id, '_price', true);
    252 
    253 
    254                         $single_product['images'] = $this->get_images( $product );
    255 
    256                         $stock_status = get_post_meta($product_id, '_stock_status', true);
    257                         $single_product['stock_status'] = $stock_status=='instock'?'IN_STOCK':'OUT_OF_STOCK';
    258 
    259 
    260                         $full_data[] = $single_product;
    261                     }
    262 
    263 
    264                 }
    265 
    266                     //echo "<pre>"; var_export($full_data); echo "</pre>";
    267                     echo  json_encode($full_data);
    268                     exit;
    269         }
    270205
    271206    public function csvexport() {
     
    336271                $single_product['name'] = $product->get_name();
    337272                $single_product['descriptionShort'] = $product->get_short_description();
    338                 $single_product['descriptionLong'] = $product->get_description();
     273                //$single_product['descriptionLong'] = $product->get_description();
     274                $single_product['descriptionLong'] = '';
     275
    339276
    340277                $single_product['price'] = wc_get_price_including_tax( $product, array('price' => $product->get_regular_price() ) );
     
    521458    // Add tracking for pages:
    522459    public function relevatracking() {
     460        /**
     461         * Don't initialize the plugin when WooCommerce is not active.
     462         */
     463        if ( ! class_exists( 'WooCommerce', false ) ) {
     464            return;
     465        }
     466
    523467        // is there any option client_id
    524468        if($this->client_id) {
     
    529473            // PRODUCT
    530474            $this->retargeting_product();
     475            // PRODUCT
     476            $this->retargeting_cart();         
    531477            // ORDER SUCCESS PAGE
    532478            $this->retargeting_confirmation();
     479            // ANY OTHER PAGE
     480            $this->retargeting_other();
    533481        }
    534482    }
     
    560508    }
    561509
     510    // CATEGORY PAGE
     511    public function retargeting_cart() {
     512        // URL:  https://pix.hyj.mobi/rt?t=d&action=w&cid=CLIENT_ID
     513        if (is_cart() ) {
     514            $this->url_js='https://pix.hyj.mobi/rt?t=d&action=w&cid='.$this->client_id;
     515            echo $this->render( 'front-page' );         
     516        }
     517    }   
     518
    562519    // PRODUCT PAGE
    563520    public function retargeting_product() {
     
    597554    }
    598555
     556    public function retargeting_other() {
     557        if(!is_front_page() && !(function_exists('is_product_category') && is_product_category()) && !is_product() && !is_order_received_page() && !is_cart()) {
     558            $this->url_js='https://pix.hyj.mobi/rt?t=d&action=s&cid='.$this->client_id;
     559            echo $this->render( 'front-page' );         
     560        }
     561    }
     562
    599563    protected $order_id ;
    600564    protected $products_name = array();
     
    609573        if($this->order_id) {
    610574        $order = new \WC_Order( $this->order_id );
     575        $this->order_id = $order->get_order_number();
    611576        $this->order_total = number_format( (float) $order->get_total() - $order->get_total_tax() - $order->get_total_shipping(), wc_get_price_decimals(), '.', '' );
    612577        foreach ( $order->get_items() as $item ) {
  • releva-nz/trunk/relevatracking.php

    r2628019 r2721057  
    1717 * Plugin URI:        https://releva.nz
    1818 * Description:       Technology for personalized advertising
    19  * Version:           2.1.0
     19 * Version:           2.1.1
    2020 * Author:            releva.nz
    2121 * License:           GPL-2.0+
     
    3030}
    3131//check a plugin (WooCommerce) is active?
    32 $all_plugins = apply_filters('active_plugins', get_option('active_plugins'));
     32$all_plugins = (!is_multisite()) ? (array) get_option('active_plugins', array()) : (array) get_site_option('active_sitewide_plugins', array());
    3333
    34 if (!stripos(implode($all_plugins), 'woocommerce.php')) {
     34$result = implode($all_plugins) . implode(',',array_keys($all_plugins));
     35
     36if (!stripos($result, 'woocommerce.php')) {
    3537    add_action( 'admin_notices', 'relevatracking_render_wc_inactive_notice' );
    3638    return;
     
    4648    $message = sprintf(
    4749        /* translators: %1$s and %2$s are <strong> tags. %3$s and %4$s are <a> tags */
    48         __( '%1$sReleva Tracking is inactive%2$s as it requires WooCommerce. Please %3$sactivate WooCommerce version 2.4.13 or newer%4$s', 'relevatracking' ),
     50        __( '%1$sreleva.nz is inactive%2$s as it requires WooCommerce. Please %3$sactivate WooCommerce version 2.4.13 or newer%4$s', 'relevatracking' ),
    4951        '<strong>',
    5052        '</strong>',
     
    6062 * This action is documented in includes/class-relevatracking-activator.php
    6163 */
    62 function activate_relevatracking() {
     64function activate_relevatracking($networkwide) {
    6365    require_once plugin_dir_path( __FILE__ ) . 'includes/class-relevatracking-activator.php';
     66
    6467    Relevatracking_Activator::activate();
    6568}
Note: See TracChangeset for help on using the changeset viewer.