Skip to content

Commit

Permalink
add mini_cart Express Checkout - Button, ref #662
Browse files Browse the repository at this point in the history
  • Loading branch information
kcppdevelopers committed May 3, 2017
1 parent 29601b0 commit 26ca345
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public function __construct($version) {
add_filter('woocommerce_thankyou_order_received_text', array($this, 'ec_order_received_text'), 10, 2);
add_action('wp_enqueue_scripts', array($this, 'ec_enqueue_scripts_product_page'));
add_action('woocommerce_before_cart_table', array($this, 'top_cart_button'));
add_action( 'woocommerce_after_mini_cart', array($this, 'mini_cart_button'));
add_filter('woocommerce_is_sold_individually', array($this, 'angelleye_woocommerce_is_sold_individually'), 10, 2);
add_filter('woocommerce_ship_to_different_address_checked', array($this, 'angelleye_ship_to_different_address_checked'), 10,1);
if ($this->is_express_checkout_credentials_is_set()) {
Expand Down Expand Up @@ -389,11 +390,24 @@ public function top_cart_button() {
}
}
}

public function mini_cart_button() {
if ($this->is_express_checkout_credentials_is_set()) {
$mini_cart_button_html = '';
$mini_cart_button_html .= $this->woocommerce_paypal_express_checkout_button_angelleye($return = true);
$mini_cart_button_html .= "<div class='clear'></div></div>";
echo apply_filters('angelleye_ec_mini_cart_button_html', $mini_cart_button_html);
}
}

public function woocommerce_paypal_express_checkout_button_angelleye($return = false) {
if (!AngellEYE_Utility::is_valid_for_use_paypal_express()) {
return false;
}
if (!defined('WOOCOMMERCE_CART')) {
define('WOOCOMMERCE_CART', true);
}
WC()->cart->calculate_totals();
if ($this->enabled == 'yes' && $this->show_on_cart == 'yes' && 0 < WC()->cart->total) {
$cart_button_html = '';
if ($this->enable_tokenized_payments == 'yes') {
Expand Down Expand Up @@ -439,6 +453,13 @@ public function checkout_message() {
if (!AngellEYE_Utility::is_valid_for_use_paypal_express()) {
return false;
}
if (!defined('WOOCOMMERCE_CHECKOUT')) {
define('WOOCOMMERCE_CHECKOUT', true);
}
if (!defined('WOOCOMMERCE_CART')) {
define('WOOCOMMERCE_CART', true);
}
WC()->cart->calculate_totals();
if (WC()->cart->total > 0) {
$ec_top_checkout_button = '';
wp_enqueue_script('angelleye_button');
Expand Down
34 changes: 17 additions & 17 deletions assets/js/angelleye-frontend.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,25 @@ jQuery(document).ready(function ($){
}
});
}
if (angelleye_frontend.is_cart == "yes"){
$(".paypal_checkout_button").click(function(){
$('.woocommerce').block({
message: null,
overlayCSS: {
background: '#fff',
opacity: 0.6
}
});
var angelleye_action;
if ($("#wc-paypal_express-new-payment-method").is(':checked')) {
angelleye_action = $(this).attr("href");
angelleye_action = angelleye_action + '&ec_save_to_account=true';
} else {
angelleye_action = $(this).attr("href");

$(".paypal_checkout_button").click(function(){
$('.woocommerce').block({
message: null,
overlayCSS: {
background: '#fff',
opacity: 0.6
}
$(this).attr("href", angelleye_action);
});
}
var angelleye_action;
if ($("#wc-paypal_express-new-payment-method").is(':checked')) {
angelleye_action = $(this).attr("href");
angelleye_action = angelleye_action + '&ec_save_to_account=true';
} else {
angelleye_action = $(this).attr("href");
}
$(this).attr("href", angelleye_action);
});

if (angelleye_frontend.is_checkout == "yes"){
var is_set_class = $("div").is(".express-provided-address");
if (is_set_class) {
Expand Down

0 comments on commit 26ca345

Please sign in to comment.