Skip to content

Commit

Permalink
Express Checkout - Ability to show/hide EC button in individual produ…
Browse files Browse the repository at this point in the history
…cts, ref #425
  • Loading branch information
kcppdevelopers committed Mar 13, 2017
1 parent 6e6d171 commit f8b1583
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public function ec_get_version() {
}

public function angelleye_ec_save_payment_method_checkbox() {
echo sprintf(
return sprintf(
'<div class="angelleye_ec_save_to_accoount_box"><p class="form-row woocommerce-SavedPaymentMethods-saveNew">
<input id="wc-%1$s-new-payment-method" name="wc-%1$s-new-payment-method" type="checkbox" style="width:auto;" />
<label for="wc-%1$s-new-payment-method" style="display:inline;">%2$s</label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,16 @@ public function __construct() {
public function buy_now_button() {
try {
global $post, $product;
$ec_html_button = '';
if ($this->enabled == 'yes' && $this->show_on_product_page == 'yes') {
$_enable_ec_button = get_post_meta($product->id, '_enable_ec_button', true);
if($_enable_ec_button == 'no') {
return;
}
if ($this->enabled == 'yes' && ($this->show_on_product_page == 'yes' || $_enable_ec_button == 'yes')) {
$ec_html_button = '';
if ($this->enable_tokenized_payments == 'yes') {
$this->function_helper->angelleye_ec_save_payment_method_checkbox();
$ec_html_button .= $this->function_helper->angelleye_ec_save_payment_method_checkbox();
}
$ec_html_button = '<div class="angelleye_button_single">';
$ec_html_button .= '<div class="angelleye_button_single">';
$_product = wc_get_product($post->ID);
$button_dynamic_class = 'single_variation_wrap_angelleye_' . $product->id;
$hide = '';
Expand Down Expand Up @@ -372,13 +376,14 @@ public function woocommerce_paypal_express_checkout_button_angelleye($return = f
return false;
}
if ($this->enabled == 'yes' && $this->show_on_cart == 'yes' && 0 < WC()->cart->total) {
$cart_button_html = '';
if ($this->enable_tokenized_payments == 'yes') {
$this->function_helper->angelleye_ec_save_payment_method_checkbox();
$cart_button_html .= $this->function_helper->angelleye_ec_save_payment_method_checkbox();
}
if($return == false) {
do_action('angelleye_ec_before_buttom_cart_button', $this);
}
$cart_button_html = '';

$angelleyeOverlay = '<div class="blockUI blockOverlay angelleyeOverlay" style="display:none;z-index: 1000; border: none; margin: 0px; width: 100%; height: 100%; top: 0px; left: 0px; opacity: 0.6; cursor: default; position: absolute; background: url(' . WC()->plugin_url() . '/assets/images/select2-spinner.gif) 50% 50% / 16px 16px no-repeat rgb(255, 255, 255);"></div>';
switch ($this->checkout_with_pp_button_type) {
case 'textbutton':
Expand Down Expand Up @@ -422,13 +427,14 @@ public function checkout_message() {
return false;
}
if (WC()->cart->total > 0) {
$ec_top_checkout_button = '';
wp_enqueue_script('angelleye_button');
echo '<div id="checkout_paypal_message" class="woocommerce-info info">';
if($this->enable_tokenized_payments == 'yes') {
$this->function_helper->angelleye_ec_save_payment_method_checkbox();
$ec_top_checkout_button .= $this->function_helper->angelleye_ec_save_payment_method_checkbox();
}
do_action('angelleye_ec_checkout_page_before_checkout_button', $this);
$ec_top_checkout_button = '';

$ec_top_checkout_button .= '<div id="paypal_box_button">';
$_angelleyeOverlay = '<div class="blockUI blockOverlay angelleyeOverlay" style="display:none;z-index: 1000; border: none; margin: 0px; padding: 0px; width: 100%; height: 100%; top: 0px; left: 0px; opacity: 0.6; cursor: default; position: absolute; background: url(' . WC()->plugin_url() . '/assets/images/select2-spinner.gif) 50% 50% / 16px 16px no-repeat rgb(255, 255, 255);"></div>';
switch ($this->checkout_with_pp_button_type) {
Expand Down
11 changes: 11 additions & 0 deletions paypal-for-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,13 @@ function angelleye_product_type_options_own($product_type){
'description' => __( '', 'paypal-for-woocommerce' ),
'default' => 'no'
);
$product_type['enable_ec_button'] = array(
'id' => '_enable_ec_button',
'wrapper_class' => '',
'label' => __( 'Enable Express Checkout Button', 'paypal-for-woocommerce' ),
'description' => __( '', 'paypal-for-woocommerce' ),
'default' => 'no'
);
return $product_type;
} else {
return $product_type;
Expand All @@ -845,6 +852,8 @@ function angelleye_woocommerce_process_product_meta_own( $post_id ){
update_post_meta( $post_id, '_paypal_billing_agreement', $_paypal_billing_agreement );
$_enable_sandbox_mode = isset( $_POST['_enable_sandbox_mode'] ) ? 'yes' : 'no';
update_post_meta( $post_id, '_enable_sandbox_mode', $_enable_sandbox_mode );
$_enable_ec_button = isset( $_POST['_enable_ec_button'] ) ? 'yes' : 'no';
update_post_meta( $post_id, '_enable_ec_button', $_enable_ec_button );
}

public static function angelleye_paypal_for_woocommerce_curl_error_handler($PayPalResult, $methos_name = null, $gateway = null, $error_email_notify = true) {
Expand Down Expand Up @@ -947,6 +956,8 @@ public function angelleye_woocommerce_pfw_ed_shipping_bulk_tool() {

} elseif ($pfw_bulk_action_type == 'enable_paypal_billing_agreement' || $pfw_bulk_action_type == 'disable_paypal_billing_agreement') {
$action_key = "_paypal_billing_agreement";
} elseif ($pfw_bulk_action_type == 'enable_express_checkout_button' || $pfw_bulk_action_type == 'disable_express_checkout_button') {
$action_key = "_enable_ec_button";
}

// All Products
Expand Down
44 changes: 24 additions & 20 deletions template/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,27 +114,29 @@
}
?>
<?php } else {
if ( !empty( $_GET['_paypal_for_woocommerce_remove_log_file'] ) || wp_verify_nonce( $_GET['_paypal_for_woocommerce_remove_log_file'], 'paypal-for-woocommerce-remove-log-file' ) ) {
$paypal_for_woocommerce_logfile_path = array('paypal_credit_card_rest' => wc_get_log_file_path('paypal_credit_card_rest'),
'braintree' => wc_get_log_file_path( 'braintree' ),
'paypal_advanced' => wc_get_log_file_path( 'paypal_advanced' ),
'paypal_express' => wc_get_log_file_path( 'paypal_express' ),
'paypal-pro' => wc_get_log_file_path( 'paypal-pro' ),
'paypal_payflow' => wc_get_log_file_path( 'paypal_payflow' )
);
$count = 0;
foreach ($paypal_for_woocommerce_logfile_path as $key => $value) {
if ( file_exists( $value ) ) {
unlink( $value );
$count = $count + 1;
if( isset($_GET['_paypal_for_woocommerce_remove_log_file'])) {
if ( !empty( $_GET['_paypal_for_woocommerce_remove_log_file'] ) || wp_verify_nonce( $_GET['_paypal_for_woocommerce_remove_log_file'], 'paypal-for-woocommerce-remove-log-file' ) ) {
$paypal_for_woocommerce_logfile_path = array('paypal_credit_card_rest' => wc_get_log_file_path('paypal_credit_card_rest'),
'braintree' => wc_get_log_file_path( 'braintree' ),
'paypal_advanced' => wc_get_log_file_path( 'paypal_advanced' ),
'paypal_express' => wc_get_log_file_path( 'paypal_express' ),
'paypal-pro' => wc_get_log_file_path( 'paypal-pro' ),
'paypal_payflow' => wc_get_log_file_path( 'paypal_payflow' )
);
$count = 0;
foreach ($paypal_for_woocommerce_logfile_path as $key => $value) {
if ( file_exists( $value ) ) {
unlink( $value );
$count = $count + 1;
}
}
$remove_logfile_tool_url = remove_query_arg( '_paypal_for_woocommerce_remove_log_file' );
wp_redirect( esc_url_raw( add_query_arg( 'count', $count, $remove_logfile_tool_url ) ) );
exit;
}
if( !empty($_GET['count']) && $_GET['count'] > 0) {
echo '<div class="updated"><p>' . __( 'Logfile has been successfully deleted.', 'paypal-for-woocommerce' ) . '</p></div>';
}
$remove_logfile_tool_url = remove_query_arg( '_paypal_for_woocommerce_remove_log_file' );
wp_redirect( esc_url_raw( add_query_arg( 'count', $count, $remove_logfile_tool_url ) ) );
exit;
}
if( !empty($_GET['count']) && $_GET['count'] > 0) {
echo '<div class="updated"><p>' . __( 'Logfile has been successfully deleted.', 'paypal-for-woocommerce' ) . '</p></div>';
}

?>
Expand All @@ -153,6 +155,8 @@
<option value="disable_no_shipping"><?php echo __('Disable No shipping required', 'paypal-for-woocommerce'); ?></option>
<option value="enable_paypal_billing_agreement"><?php echo __('Enable PayPal Billing Agreement', 'paypal-for-woocommerce'); ?></option>
<option value="disable_paypal_billing_agreement"><?php echo __('Disable PayPal Billing Agreement', 'paypal-for-woocommerce'); ?></option>
<option value="enable_express_checkout_button"><?php echo __('Enable Express Checkout Button', 'paypal-for-woocommerce'); ?></option>
<option value="disable_express_checkout_button"><?php echo __('Disable Express Checkout Button', 'paypal-for-woocommerce'); ?></option>
</select>
</div>
</div>
Expand Down Expand Up @@ -238,7 +242,7 @@
<div class="wrap">
<div class="angelleye-paypal-for-woocommerce-shipping-tools-wrap">
<div><br></div>
<p><a href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'paypal_for_woocommerce_remove_log_file' ), 'paypal-for-woocommerce-remove-log-file', '_paypal_for_woocommerce_remove_log_file' ) ); ?>" class="delete_template button"><?php _e( 'Clear All Log Files', 'paypal-for-woocommerce' ); ?></a><span><?php echo str_repeat('&nbsp;', 3); echo __( 'This will remove all the log file of PayPal for WooCoomerce plugin.', 'paypal-for-woocommerce' ); ?> </span></p>
<p><a href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'paypal_for_woocommerce_remove_log_file', 'true' ), 'paypal-for-woocommerce-remove-log-file', '_paypal_for_woocommerce_remove_log_file' ) ); ?>" class="delete_template button"><?php _e( 'Clear All Log Files', 'paypal-for-woocommerce' ); ?></a><span><?php echo str_repeat('&nbsp;', 3); echo __( 'This will remove all the log file of PayPal for WooCoomerce plugin.', 'paypal-for-woocommerce' ); ?> </span></p>
</div>
</div>
<?php
Expand Down

0 comments on commit f8b1583

Please sign in to comment.