Created
November 4, 2015 15:49
-
-
Save marketpress-support-team/856e832c55bd31c732a7 to your computer and use it in GitHub Desktop.
Stellt Kompatibilität zwischen WooCommerce German Market 2.6.3 und WooCommerce PayPal Express Gateway 3.5.1 her. Nutzung ohne Gewähr, vorab testen!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: WooCommerce German Market | PayPal Express Gateway | |
* Description: <strong>Nutzung ohne Gewähr, vorab testen!</strong> Stellt Kompatibilität zwischen WooCommerce German Market 2.6.3 und WooCommerce PayPal Express Gateway 3.5.1 her. | |
* Version: 2015.11 | |
* Author: Caspar Hübinger für MarketPress | |
* Author URI: https://marketpress.de/ | |
* License: GNU General Public License v3 or later | |
* License URI: http://www.gnu.org/licenses/gpl-3.0.html | |
*/ | |
if ( ! defined( 'ABSPATH' ) ) { | |
exit; | |
} | |
/** | |
* WGM checkout routine with PayPal Express Gateway. | |
* | |
* @return void | |
*/ | |
function mp151104_wgm_ppxprss__checkout_routine() { | |
if ( ! class_exists( 'WGM_Template' ) || ! class_exists( 'WC_Gateway_PayPal_Express' ) ) { | |
add_action( 'admin_notices', 'mp151104_wgm_ppxprss__admin_notice' ); | |
return; | |
} | |
// Check if PP Express has been selected as payment method | |
$maybe_paypal_express = WC()->session->first_checkout_post_arraypayment_method; | |
if ( isset( $maybe_paypal_express ) && $maybe_paypal_express === 'paypal_express' ) { | |
// Disable WGM’s second checkout. | |
remove_filter( 'woocommerce_after_checkout_validation', array( 'WGM_Template', 'do_de_checkout_after_validation' ), 1, 1 ); | |
// Add session flag if revocation box is available and was checked. | |
if ( isset( $_POST['widerruf'] ) && wc_get_page_id( 'widerruf' ) > 0 ) { | |
WC()->session->first_checkout_post_arraywiderruf = 'on'; | |
} | |
// Add session flag if revocation for digital products box is available and was checked. | |
if ( isset( $_POST['widerruf_digital'] ) && wc_get_page_id( 'widerruf_digital' ) > 0 ) { | |
WC()->session->first_checkout_post_arraywiderruf_digital = 'on'; | |
} | |
// Hide checkboxes for revocation when returning. | |
add_action( 'wp_head', 'mp151104_wgm_ppxprss__add_css' ); | |
} | |
} | |
add_action( 'init', 'mp151104_wgm_ppxprss__checkout_routine' ); | |
/** | |
* Hide disclaimer boxes when returning from PayPal. | |
* | |
* @return void | |
*/ | |
function mp151104_wgm_ppxprss__add_css() { | |
?> | |
<!-- WooCommerce German Market + PayPal Express --> | |
<style type="text/css" media="screen"> | |
.paypal-express-hide-terms .terms label[for="widerruf"], | |
.paypal-express-hide-terms .terms label[for="widerruf_digital"], | |
.paypal-express-hide-terms .terms #widerruf, | |
.paypal-express-hide-terms .terms #widerruf_digital { | |
display: none !important; | |
} | |
</style> | |
<!-- /WooCommerce German Market --> | |
<?php | |
} | |
/** | |
* Error admin notice. | |
* | |
* @return void | |
*/ | |
function mp151104_wgm_ppxprss__admin_notice() { | |
$msg = sprintf( | |
'<p>%s</p>', | |
'<strong>WooCommerce German Market</strong> und/oder <strong>PayPal Express Gateway</strong> sind nicht aktiv.<br><strong>WooCommerce German Market | PayPal Express Gateway</strong> kann nicht ausgeführt werden.' | |
); | |
$classes = 'notice-error'; | |
printf( | |
'<div class="notice %1$s">%2$s</div>', | |
$classes, | |
$msg | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment