Plugin Directory

Changeset 2454116


Ignore:
Timestamp:
01/11/2021 07:37:59 PM (5 years ago)
Author:
wpconcierges
Message:

fixed set parameter issue for incoming outgoing click id params

Location:
order-postback-woo/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • order-postback-woo/trunk/README.txt

    r2452150 r2454116  
    55Requires at least: 3.1
    66Tested up to: 5.6
    7 Stable tag: 1.0.4
     7Stable tag: 1.0.5
    88Requires PHP: 5.6 or above
    99License: GPLv2 or later
     
    3737zapier webhooks
    3838image url callback
     39CAKE
    3940Any affiliate network that supports image or server 2 server postback calls
    4041
     
    8283
    8384== Changelog ==
     85= 1.0.5 =
     86fixed incoming outgoing variable issues if on version 1.0.3 ore 1.0.4
     87
    8488= 1.0.4 =
    8589fixed replacement variable offset issue if on version 1.0.3
  • order-postback-woo/trunk/includes/class-order-postback-woo.php

    r2452150 r2454116  
    7171            $this->version = ORDER_POSTBACK_WOO_VERSION;
    7272        } else {
    73             $this->version = '1.0.4';
     73            $this->version = '1.0.5';
    7474        }
    7575        $this->plugin_name = $this->order_postback_woo = 'order-postback-woo';
  • order-postback-woo/trunk/order-postback-woo.php

    r2452150 r2454116  
    1717 * Plugin URI:        https://www.wpconcierges.com/plugins/order_postback_woo/
    1818 * Description:       This plugin sends your order information from your Woocomerce store as a key/value pair to any url of your choice, using either a POST or GET.  This is useful if you would like to store your orders or process orders outside of your Woocommerce store.
    19  * Version:           1.0.4
     19 * Version:           1.0.5
    2020 * Author:            WpConcierges
    2121 * Author URI:        https://www.wpconcierges.com/
     
    3838 * Rename this for your plugin and update it as you release new versions.
    3939 */
    40 define( 'ORDER_POSTBACK_WOO_VERSION', '1.0.4' );
     40define( 'ORDER_POSTBACK_WOO_VERSION', '1.0.5' );
    4141
    4242/**
  • order-postback-woo/trunk/public/class-order-postback-woo-public.php

    r2452150 r2454116  
    245245
    246246    private function set_parameters($metas){
     247       
    247248        $params = array();
    248249        $cookie_keys = array('opw_incoming_click_id','opw_outgoing_click_id');
     
    271272       $params[$metas['opw_outgoing_click_id']] = $_COOKIE[$metas['opw_incoming_click_id']];
    272273        } 
    273 
     274     print_r($params);
    274275        return $params;
    275276    }
     
    311312
    312313   private function can_fire_check($params){
    313     if($params['opw_fire']=="no"){
     314      if($params['opw_fire']=="no"){
    314315          $this->can_fire = true;
    315316      }else{
     
    319320      $out_click_id = $params['opw_outgoing_click_id'];
    320321     
    321       if(isset($_COOKIE[$click_id])){
    322      $this->postback_params[$out_click_id] = $_COOKIE[$click_id];
     322     
     323        if(isset($_COOKIE[$click_id])){
     324             $this->postback_params[$out_click_id] = $_COOKIE[$click_id];
    323325           
    324      if(($params['opw_fire'] == "yes") && strlen($this->postback_params[$out_click_id])){
    325         $this->can_fire = true;
    326      }
    327       }
     326             if(($params['opw_fire'] == "yes") && strlen($this->postback_params[$out_click_id])){
     327                $this->can_fire = true;
     328             }
     329       } 
    328330   }   
    329331
     
    340342   
    341343    private function get_postback_link_field($link,$field_to_get){
     344            global $wpdb;
    342345        $field_check = array($field_to_get);
    343346        $fields = array();
    344347        $post_id = $link['ID'];
    345348       
    346         $metas = get_post_meta($post_id);
     349        $sql = $wpdb->prepare("SELECT * FROM {$wpdb->prefix}postmeta WHERE post_id=%d",array($post_id));
     350
     351        $metas = $wpdb->get_results( $sql, 'ARRAY_A');
    347352       
    348353       
     
    358363    }
    359364   
     365     
     366   
    360367    private function get_postback_link_fields($link){
    361       $field_check = array('opw_url','opw_method','opw_key_values_number','opw_headers');
    362         $fields = array();
    363         $fields['opw_url'] = $link['post_content'];
    364         $post_id = $link['ID'];
    365        
    366         $metas = get_post_meta($post_id);
    367         $datas = array();
    368         foreach($metas as $meta_key => $meta_value){
    369             if(in_array($meta_key,$field_check)){
    370                 $fields[$meta_key]=current($meta_value);
    371             }else{
     368      $field_check = array('opw_url','opw_method','opw_fire','opw_incoming_click_id','opw_outgoing_click_id','opw_key_values_number');
     369    $fields = array();
     370    $fields['opw_url'] = $link['post_content'];
     371    $post_id = $link['ID'];
     372   
     373    $metas = get_post_meta($post_id);
     374    $datas = array();
     375    foreach($metas as $meta_key => $meta_value){
     376        if(in_array($meta_key,$field_check)){
     377            $fields[$meta_key]=current($meta_value);
     378        }else{
     379       
     380            $tmp = explode("_",$meta_key);
    372381               
    373            
    374                 $tmp = explode("_",$meta_key);
    375                  
    376                   if(isset($tmp[2]) && in_array($tmp[1],array('key','value'))){
    377                       $counter = $tmp[2];
    378                     if(is_numeric($counter)){
    379                           if((strpos($meta_key,"_key_"))>0){
    380                               $datas['key_values'][$counter]['key'] = current($meta_value);
     382                if(isset($tmp[2]) && in_array($tmp[1],array('key','value'))){
     383                    $counter = $tmp[2];
     384                  if(is_numeric($counter)){
     385                        if((strpos($meta_key,"_key_"))>0){
     386                            $datas['key_values'][$counter]['key'] = current($meta_value);
     387                    }
     388               
     389                        if((strpos($meta_key,"_value_"))>0){
     390                            $datas['key_values'][$counter]['value'] = current($meta_value);
    381391                        }
    382                  
    383                           if((strpos($meta_key,"_value_"))>0){
    384                               $datas['key_values'][$counter]['value'] = current($meta_value);   
    385                           }
    386                     }
    387                 }
    388             }
    389         }
    390            
    391         foreach($datas['key_values'] as $data){
    392             $fields[$data['key']]=$data['value'];
    393         }
    394        
    395         $fields = $this->set_parameters($fields);
    396        
    397         return $fields;
     392                  }
     393              }
     394        }
     395    }
     396       
     397    foreach($datas['key_values'] as $data){
     398        $fields[$data['key']]=$data['value'];
     399    }
     400   
     401    $fields = $this->set_parameters($fields);
     402   
     403    return $fields;
    398404    }
    399405   
     
    418424        $opw = $this->get_postback_link($link);
    419425     
    420            $this->can_fire_check($opw);   
     426           $this->can_fire_check($opw);   
     427           
    421428           if($this->can_fire){
    422429            $this->postback_url = $opw['opw_url'];
    423             $this->postback_params = $this->get_postback_params($opw);
     430           $this->postback_params = $this->get_postback_params($opw);
     431         
    424432         
    425433            $args = array();
    426        
    427              
     434     
    428435            if($opw['opw_method'] == "get"){
    429436              if(strpos($this->postback_url,"?")>0){
     
    437444            }else{
    438445              $args = array("body"=>array($this->postback_params));
    439            
    440               if(count($headers)){
    441                 $args['headers'] = $headers;
    442               }
    443             $response = wp_remote_post($this->postback_url,$args); 
    444              
    445           }
     446              $response = wp_remote_post($this->postback_url,$args);   
     447           
     448                }
    446449       }
    447450         
Note: See TracChangeset for help on using the changeset viewer.