This file contains 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 | |
// Function to get the email from WooCommerce Checkout or Order | |
function get_wc_checkout_email() { | |
if ( $order_id = WC()->session->get('order_awaiting_payment') ) { | |
$order = wc_get_order($order_id); | |
return $order->get_billing_email(); | |
} else { | |
return WC()->checkout()->get_value('billing_email'); | |
} |
This file contains 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 | |
add_filter('ppcp_create_order_request_body_data', static function (array $data): array { | |
if (isset($data['purchase_units'][0]['items'][0]['description'])) { | |
$data['purchase_units'][0]['items'][0]['description'] = ''; | |
} | |
return $data; | |
}); |
This file contains 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 | |
add_filter('ppcp_create_order_request_body_data', function (array $data): array { | |
foreach ($data['purchase_units'] as $index => $purchase_unit) { | |
// extract order number from custom_id | |
$order_number = isset($purchase_unit['custom_id']) ? $purchase_unit['custom_id'] : 'N/A'; | |
foreach ($purchase_unit['items'] as $item_index => $item) { | |
$data['purchase_units'][$index]['items'][$item_index]['description'] = ''; | |
unset($data['purchase_units'][$index]['items'][$item_index]['sku']); |
This file contains 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 | |
// PHP function to unset Stripe gateway | |
add_filter( 'woocommerce_available_payment_gateways', 'payment_gateway_disable_countries' ); | |
function payment_gateway_disable_countries( $gateways ) { | |
if ( is_admin() ) { | |
return $gateways; | |
} | |
if ( ! is_object( WC()->customer ) OR ! method_exists( WC()->customer, 'get_billing_country' ) ) { |
This file contains 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 | |
function customize_paypal_invoice_number( $data ) { | |
// Access the global WooCommerce object | |
global $woocommerce; | |
// Get the current order | |
$order = $woocommerce->session->get('order_awaiting_payment') ? | |
wc_get_order($woocommerce->session->get('order_awaiting_payment')) : null; |
This file contains 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 | |
function remove_paypal_payment_gateways_from_change_payment_endpoint( $available_gateways ) { | |
if ( is_wc_endpoint_url( 'order-pay' ) && isset( $_GET['change_payment_method'] ) ) { | |
unset( $available_gateways['ppcp-gateway'] ); | |
unset( $available_gateways['ppcp-credit-card-gateway'] ); | |
} |
This file contains 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 | |
/** | |
* // functions.php | |
* Customize order number by adding a prefix based on the current blog ID | |
*/ | |
add_filter('woocommerce_order_number', 'multisite_change_woocommerce_order_number', 1, 2); | |
function multisite_change_woocommerce_order_number($order_id, $order) { | |
$blog_id = get_current_blog_id(); |
This file contains 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 | |
function add_ppcp_gateway_title_link( $title, $id ) { | |
if ( 'ppcp-gateway' === $id ) { | |
$title .= sprintf( ' <a href="%s" class="about_ppcp" onclick="javascript:window.open(\'%s\',\'WIPPcp\',\'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=1060, height=700\'); return false;" title="What is PayPal?">What is PayPal?</a>', esc_url( 'https://www.paypal.com/us/webapps/mpp/paypal-popup' ), esc_url( 'https://www.paypal.com/us/webapps/mpp/paypal-popup' ) ); | |
} | |
return $title; | |
} | |
add_filter( 'woocommerce_gateway_title', 'add_ppcp_gateway_title_link', 10, 2 ); |
This file contains 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 | |
function woocommerce_paypal_payments_card_button_gateway_icon( $icon, $id ) { | |
if ( $id === 'ppcp-card-button-gateway' ) { | |
return '<img src="https://upload.wikimedia.org/wikipedia/commons/2/2a/Mastercard-logo.svg" alt="Mastercard" /> <img src="https://upload.wikimedia.org/wikipedia/commons/0/04/Visa.svg" alt="Visa" /> <img src="https://www.paypalobjects.com/webstatic/mktg/Logo/pp-logo-100px.png" alt="PayPal Payments" />'; | |
} else { | |
return $icon; | |
} | |
} | |
add_filter( 'woocommerce_gateway_icon', 'woocommerce_paypal_payments_card_button_gateway_icon', 10, 2 ); |
This file contains 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 | |
// removes PayPal smart buttons on single product page for a product with a given id | |
function ppcp_remove_single_product_buttons() { | |
$product = wc_get_product(); | |
if ($product) { | |
if ( $product->get_id() == 24 ) { | |
return false; | |
} | |
else { return true;} |
NewerOlder