Plugin Directory

Changeset 1889063


Ignore:
Timestamp:
06/07/2018 04:40:13 PM (8 years ago)
Author:
referralcandy
Message:

Added option to enable post-purchase popup

Location:
referralcandy-for-woocommerce/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • referralcandy-for-woocommerce/trunk/includes/class-wc-referralcandy-integration.php

    r1860982 r1889063  
    5050                    'desc_tip'          => false,
    5151                    'default'           => ''
     52                ],
     53                'popup' => [
     54                    'title'             => __('Post-purchase Popup', 'woocommerce-referralcandy'),
     55                    'label'             => __('Enable post-purchase Popup', 'woocommerce-referralcandy'),
     56                    'type'              => 'checkbox',
     57                    'desc_tip'          => false,
     58                    'default'           => ''
     59                ],
     60                'popup_quickfix' => [
     61                    'title'             => __('Post-purchase Popup Quickfix', 'woocommerce-referralcandy'),
     62                    'label'             => __('Popup is breaking the checkout page?'.'
     63                                                Try enabling this option to apply the quickfix!',
     64                                                'woocommerce-referralcandy'),
     65                    'type'              => 'checkbox',
     66                    'desc_tip'          => false,
     67                    'default'           => ''
    5268                ]
    5369            ];
     
    5672        public function sanitize_settings($settings) {
    5773            return $settings;
     74        }
     75
     76        public function is_option_enabled($option_name) {
     77            return $this->get_option($option_name) == 'yes'? true : false;
    5878        }
    5979
     
    7696            $billing_last_name  = $wc_pre_30? $order->billing_last_name : $order->get_billing_last_name();
    7797            $billing_email      = $wc_pre_30? $order->billing_email : $order->get_billing_email();
     98            $encoded_email      = urlencode($billing_email);
    7899            $order_total        = $order->get_total();
    79100            $order_currency     = $wc_pre_30? $order->get_order_currency() : $order->get_currency();
     
    81102
    82103            $divData = [
    83                 'id'                => 'refcandy-mint',
     104                'id'                => $this->is_option_enabled('popup')? 'refcandy-popsicle' : 'refcandy-mint',
    84105                'data-app-id'       => $this->get_option('app_id'),
    85106                'data-fname'        => urlencode($billing_first_name),
    86107                'data-lname'        => urlencode($billing_last_name),
    87                 'data-email'        => urlencode($billing_email),
     108                'data-email'        => $this->is_option_enabled('popup')? $billing_email : $encoded_email,
    88109                'data-amount'       => $order_total,
    89110                'data-currency'     => $order_currency,
    90111                'data-timestamp'    => $timestamp,
    91                 'data-signature'    => md5($billing_email.','.$billing_first_name.','.$order_total.','.$timestamp.','.$this->get_option('secret_key')),
    92                 'data-external-reference-id' => $order_number
     112                'data-external-reference-id' => $order_number,
     113                'data-signature'    => md5($billing_email.','.$billing_first_name.','.$order_total.','.$timestamp.','.$this->get_option('secret_key'))
    93114            ];
    94115
     116            $popsicle_script = '<script>(function(e){var t,n,r,i,s,o,u,a,f,l,c,h,p,d,v;z="script";l="refcandy-purchase-js";c="refcandy-popsicle";p="go.referralcandy.com/purchase/";t="data-app-id";r={email:"a",fname:"b",lname:"c",amount:"d",currency:"e","accepts-marketing":"f",timestamp:"g","referral-code":"h",locale:"i","external-reference-id":"k",signature:"ab"};i=e.getElementsByTagName(z)[0];s=function(e,t){if(t){return""+e+"="+encodeURIComponent(t)}else{return""}};d=function(e){return""+p+h.getAttribute(t)+".js?lightbox=1&aa=75&"};if(!e.getElementById(l)){h=e.getElementById(c);if(h){o=e.createElement(z);o.id=l;a=function(){var e;e=[];for(n in r){u=r[n];v=h.getAttribute("data-"+n);e.push(s(u,v))}return e}();o.src="//"+d(h.getAttribute(t))+a.join("&");return i.parentNode.insertBefore(o,i)}}})(document);</script>';
     117
     118            $mint_script = '<script>(function(e){var t,n,r,i,s,o,u,a,f,l,c,h,p,d,v;z="script";l="refcandy-purchase-js";c="refcandy-mint";p="go.referralcandy.com/purchase/";t="data-app-id";r={email:"a",fname:"b",lname:"c",amount:"d",currency:"e","accepts-marketing":"f",timestamp:"g","referral-code":"h",locale:"i","external-reference-id":"k",signature:"ab"};i=e.getElementsByTagName(z)[0];s=function(e,t){if(t){return""+e+"="+t}else{return""}};d=function(e){return""+p+h.getAttribute(t)+".js?aa=75&"};if(!e.getElementById(l)){h=e.getElementById(c);if(h){o=e.createElement(z);o.id=l;a=function(){var e;e=[];for(n in r){u=r[n];v=h.getAttribute("data-"+n);e.push(s(u,v))}return e}();o.src=""+e.location.protocol+"//"+d(h.getAttribute(t))+a.join("&");return i.parentNode.insertBefore(o,i)}}})(document);</script>';
     119
     120            $quickfix = '';
     121            if ($this->is_option_enabled('popup') && $this->is_option_enabled('popup_quickfix')) {
     122                $quickfix = '<style>html { position: relative !important; }</style>';
     123            }
     124
    95125            $div = '<div '.implode(' ', array_map(function ($v, $k) { return $k . '="'.addslashes($v).'"'; }, $divData, array_keys($divData))).'></div>';
    96             $script = '<script>(function(e){var t,n,r,i,s,o,u,a,f,l,c,h,p,d,v;z="script";l="refcandy-purchase-js";c="refcandy-mint";p="go.referralcandy.com/purchase/";t="data-app-id";r={email:"a",fname:"b",lname:"c",amount:"d",currency:"e","accepts-marketing":"f",timestamp:"g","referral-code":"h",locale:"i","external-reference-id":"k",signature:"ab"};i=e.getElementsByTagName(z)[0];s=function(e,t){if(t){return""+e+"="+t}else{return""}};d=function(e){return""+p+h.getAttribute(t)+".js?aa=75&"};if(!e.getElementById(l)){h=e.getElementById(c);if(h){o=e.createElement(z);o.id=l;a=function(){var e;e=[];for(n in r){u=r[n];v=h.getAttribute("data-"+n);e.push(s(u,v))}return e}();o.src=""+e.location.protocol+"//"+d(h.getAttribute(t))+a.join("&");return i.parentNode.insertBefore(o,i)}}})(document);</script>';
    97             echo $div.$script;
     126
     127            $script = $this->is_option_enabled('popup')? $popsicle_script : $mint_script;
     128
     129            echo $div.$script.$quickfix;
    98130        }
    99131    }
  • referralcandy-for-woocommerce/trunk/readme.txt

    r1880231 r1889063  
    7171== Changelog ==
    7272
     73= 1.3.6 =
     74* Added an option to enable the post-purchase popup widget on the checkout completed / thank you page =
     75
    7376= 1.3.5 =
    7477* Fixed whitescreen of death issue when the Woocommerce plugin is deactivated while the ReferralCandy plugin is active
  • referralcandy-for-woocommerce/trunk/woocommerce-referralcandy.php

    r1880231 r1889063  
    77 * Author URI: http://www.referralcandy.com
    88 * Text Domain: woocommerce-referralcandy
    9  * Version: 1.3.5
     9 * Version: 1.3.6
    1010 *
    1111 * This program is free software: you can redistribute it and/or modify
Note: See TracChangeset for help on using the changeset viewer.