Skip to content

Instantly share code, notes, and snippets.

View vanbo's full-sized avatar

Ivan Andreev vanbo

View GitHub Profile
@vanbo
vanbo / wc-epaybg-no-pay-page-reload-after-form-submit
Last active September 12, 2022 13:11
WooCommerce ePaybg: Do not allow Pay page reload after customer is sent to ePaybg
add_action( 'woocommerce_receipt_epaybg', 'vanbo_initiate_epaybg_request_hooks', 9 );
/**
* Replaces the gateway original action with our own
*/
function vanbo_initiate_epaybg_request_hooks() {
$gateway = vanbo_get_epaybg_gateway();
if ( false == $gateway ) {
return;
}
@vanbo
vanbo / wc-borica-work-around-polylang-language-storage
Created September 14, 2020 12:14
WC Borica - Work around Polylang language storage
/**
* IMPORTANT: Past this snippet to your "child-theme\functions.php" file.
*/
add_action( 'init', 'vanbo_store_polylang_language', 99 );
/**
* Saves the Polylang last used language by the current user
*/
function vanbo_store_polylang_language() {
if ( ! function_exists( 'WC' ) || ! WC()->session ) {
@vanbo
vanbo / wc-trustcommerce-add-operator-id-requests
Created August 18, 2020 12:24
WooCommerce TrustCommerce add operator ID to requests
/**
* IMPORTANT: Add the code to your "child-theme/functions.php" file
*/
add_filter( 'wc_trustcommerce_process_single_payment_request', 'vanbo_tc_add_operator_to_requests', 10 );
add_filter( 'wc_trustcommerce_process_profile_payment_request_request', 'vanbo_tc_add_operator_to_requests', 10 );
add_filter( 'wc_trustcommerce_create_customer_profile_request', 'vanbo_tc_add_operator_to_requests', 10 );
add_filter( 'wc_trustcommerce_update_customer_profile_request', 'vanbo_tc_add_operator_to_requests', 10 );
add_filter( 'wc_refund_payment_request_trustcommerce', 'vanbo_tc_add_operator_to_requests', 10 );
add_filter( 'wc_capture_payment_request_trustcommerce', 'vanbo_tc_add_operator_to_requests', 10 );
@vanbo
vanbo / wc-borica-filter-payment-request
Created July 29, 2020 13:20
WC Borica Filter Payment Request
/**
* NOTE: Add the code to your "child-theme/functions.php" file
*/
add_filter( 'wc_borica_form_request_parameters', 'vanbodevelops_filter_borica_request', 10, 3 );
function vanbodevelops_filter_borica_request( $params, $order, $gateway ) {
// NOTE: Use each block as needed.
// 1. Change the Borica payment page language
// 'BG' - bulgarian, 'EN' - english
$params['language'] = 'EN';
@vanbo
vanbo / wc-cancel-failed-payment-orders
Last active July 15, 2020 21:06
WooCommerce Cancel Failed Payment Orders
/**
* Cancel all failed orders after held duration
* The method is adapted from the WooCommerce "wc_cancel_unpaid_orders" function and uses 'woocommerce_cancel_unpaid_orders' schedule hook
*
* Code location: Add the code to your "child-theme/functions.php" file
*
* Requirements: "Product > Inventory > Manage Stock" enabled, and time set in the "Product > Inventory > Hold stock (minutes)" setting.
*/
function vanbo_cancel_failed_orders() {
$held_duration = get_option( 'woocommerce_hold_stock_minutes' );
@vanbo
vanbo / woocommerce-paysafe-json-pay-page-payment
Created June 9, 2020 20:30
WooCommece Paysafe JSON Pay Page Payment
add_filter( 'wc_paysafe_layover_on_checkout', 'vanbo_wc_paysafe_layover_on_checkout' );
function vanbo_wc_paysafe_layover_on_checkout( $on_checkout ) {
return true;
}
@vanbo
vanbo / woocommerce-complete-order-from-link-to-edit-order-screen
Last active June 2, 2020 15:57
Complete the order from a link to the Edit order screen
@vanbo
vanbo / woocommerce-paytrace-change-request-timeout
Created May 4, 2020 17:43
WooCommerce Paytrace change request timeout
/**
* NOTE: Add the code to the 'theme/functions.php" file
*/
add_filter( 'wc_paytrace_request_timeout', 'vanbo_paytrace_edit_timeout', 10 );
/**
* @param int $timeout The current seconds
*
* @return int Return the seconds you want the timeout to be
*/
function vanbo_paytrace_edit_timeout($timeout){
@vanbo
vanbo / wc-paytrace-force-api-to-user-tls-1-2
Created February 17, 2020 09:47
WC Paytrace - Force API to use TLS 1.2
add_action( 'http_api_curl', 'paytrace_http_api_curl', 10, 3 );
/**
* Force posts to Paytrace to use TLS v1.2.
*
* @param string $handle
* @param mixed $r
* @param string $url
*/
function paytrace_http_api_curl( $handle, $r, $url ) {
if ( strstr( $url, 'https://' ) && ( strstr( $url, 'api.paytrace.com' ) || strstr( $url, 'paytrace.com/api' ) ) ) {
@vanbo
vanbo / wc-epaytouch-payment-setup-request
Created January 23, 2020 16:18
WC Epay.bg OneTouch - Filter Setup Payment Request
/**
* Place the code in your theme/functions.php file
*/
add_filter( 'wc_epay_one_touch_payment_setup_params', 'prefix_epaytouch_setup_params', 10, 4 );
function prefix_epaytouch_setup_params( $params, $device_id, $token, $account_payment_class ) {
if ( isset( $params['EXP'] ) ) {
// remove the expiration time
unset( $params['EXP'] );
}