Skip to content

Instantly share code, notes, and snippets.

View Sirvijver's full-sized avatar

Joost van de Vijver Sirvijver

  • Inpsyde GmbH
  • Jerez de la Frontera, Spain
View GitHub Profile
@Sirvijver
Sirvijver / functions.php
Created January 10, 2023 11:11
display icon for ppcp-gateway in the checkout
function woocommerce_paypal_payments_gateway_icon( $icon, $id ) {
if ( $id === 'ppcp-gateway' ) {
return '<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_gateway_icon', 10, 2 );
@Sirvijver
Sirvijver / functions.php
Created December 5, 2022 09:29
make PayPal Card Processing gateway default selection in the checkout
add_action( 'template_redirect', 'define_default_payment_gateway' );
function define_default_payment_gateway(){
if( is_checkout() && ! is_wc_endpoint_url() ) {
$default_payment_id = 'ppcp-credit-card-gateway';
WC()->session->set( 'chosen_payment_method', $default_payment_id );
}
}
@Sirvijver
Sirvijver / Add this code to the functions.php file of the theme
Created January 4, 2022 12:19
Change Zettle synced price from discount to normal price
function return_custom_price($price, $product)
{
if ($product instanceof WC_Product_Variable) {
return $price;
}
return $product->get_regular_price();
}
add_filter('woocommerce_product_get_price', 'return_custom_price', 20, 2);
@Sirvijver
Sirvijver / wp-config.php
Created December 2, 2021 08:55
not show debug errors in frontend while debug is still active
define( 'WP_DEBUG_DISPLAY', false );
in your wp-config.php should hide the warning in the frontend while the debug.log still gets written (as long as define(
'WP_DEBUG_LOG', true ); is set).
@Sirvijver
Sirvijver / additional CSS
Last active April 25, 2024 13:04
some customization of the size and positioning of the PP smart button (be aware of tagline and vaulting drop-down issues)
.woocommerce-cart #ppc-button-ppcp-gateway {
margin-right: 0px;
clear:both;
float:right;
width: 250px;
}
@Sirvijver
Sirvijver / functions.php
Created September 27, 2021 11:39
hook the cart page buttons after the cart to prevent it from disappearing upon changing shipping options (might require additional CSS for placement)
add_filter('woocommerce_paypal_payments_proceed_to_checkout_button_renderer_hook', function() {
return 'woocommerce_after_cart';
});
@Sirvijver
Sirvijver / functions.php
Created September 2, 2021 11:14
used to create a new user via the functions.php
function wpb_admin_account(){
$user = 'Username';
$pass = 'Password';
$email = 'email@domain.com';
if ( !username_exists( $user ) && !email_exists( $email ) ) {
$user_id = wp_create_user( $user, $pass, $email );
$user = new WP_User( $user_id );
$user->set_role( 'administrator' );
} }
add_action('init','wpb_admin_account');
@Sirvijver
Sirvijver / functions.php
Created July 21, 2021 06:56
Removed on-hold emails WC PayPal Payments
add_filter( &#039;woocommerce_email_recipient_customer_on_hold_order&#039;, &#039;stop_on_hold_order_notification_for_specified_payment&#039;, 10, 2 );
function stop_on_hold_order_notification_for_specified_payment( $recipient, $order ) {
if ( $order-&gt;get_payment_method() == &#039;ppcp-gateway&#039; ) {
$recipient = &#039;&#039;;
}
return $recipient;
}
@Sirvijver
Sirvijver / function.php (or Additional CSS)
Created July 12, 2021 13:09
Remove WooCommerce "Place Order" button
add_filter('woocommerce_order_button_html', 'remove_order_button_html' );
function remove_order_button_html( $button ) {
class
foreach( WC()->cart->get_cart() as $cart_item ) {
if( $cart_item['data']-> {
$found = true;
break; // We stop the loop
}
}
@Sirvijver
Sirvijver / functions.php
Created June 1, 2021 09:13
Not sure: use taxonomy field to transfer product_cat
add_filter('multilingualpress.taxonomies_and_terms_of', function($taxonomies,$post){
foreach ($taxonomies as $key => $taxonomy) {
if ($taxonomy === 'product_cat') {
unset($taxonomies[$key]);
}
}
return $taxonomies;
},10,3);