Uncategorized

ajax + wordpress

in header.php

$(document).ready(function() {

    $(“#paymentmethod select”).change(function(){            
      var data = {
    action: ‘showPayPalAfterRev’,
    payactiveh: $(“#paymentmethod select option:selected”).val()
    };  
     jQuery.post( ‘<?php bloginfo(‘siteurl’); ?>/wp-admin/admin-ajax.php’, data, function(response) {
                                         });

        if($(this).val() == ‘نقدا بالفندق’){ // or this.value == ‘volvo’
  $(“.cashmoney”).fadeIn(“10000”);
  $(“.converttobank”).hide();
  } else if ($(this).val() == ‘تحويل بنكي’) {
  $(“.converttobank”).fadeIn(“10000”);
  $(“.cashmoney”).hide();      
  }
  else if ($(this).val() == ‘Pay Pal’) {
  $(“.converttobank”).hide();
  $(“.cashmoney”).hide();      
  }

});

});

</script>

 

 

in functions.php

add_action(‘wp_ajax_showPayPalAfterRev’, ‘showPayPalAfterRev’);

function showPayPalAfterRev() {
    echo $_POST[‘payactiveh’];
    if($_POST[‘payactiveh’]==’نقدا بالفندق’){
 update_option( booking_paypal_is_active, Off );   
    }elseif($_POST[‘payactiveh’]==’تحويل بنكي’){
 update_option( booking_paypal_is_active, Off );           
    }elseif($_POST[‘payactiveh’]==’Pay Pal’){
 update_option( booking_paypal_is_active, On );           
    }
     
 
}

?>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s