Skip to content

Instantly share code, notes, and snippets.

View barbareshet's full-sized avatar
🎯
Focusing

ido barnea barbareshet

🎯
Focusing
View GitHub Profile
@barbareshet
barbareshet / woocommerce_coupon_column
Last active December 3, 2024 07:05
Adding Coupon Column to Woocommerce Orders admin
<?php
// Add a new column to the orders list
add_filter( 'manage_edit-shop_order_columns', 'add_coupon_code_column', 20 );
function add_coupon_code_column( $columns ) {
// Insert the new column after the 'order_status' column
$new_columns = array();
foreach ( $columns as $key => $column ) {
$new_columns[ $key ] = $column;
if ( 'order_status' === $key ) {
$new_columns['coupons_used'] = __( 'Coupons Used', 'your-textdomain' );
// Get The Page ID You Need
get_option( 'woocommerce_shop_page_id' );
get_option( 'woocommerce_cart_page_id' );
get_option( 'woocommerce_checkout_page_id' );
get_option( 'woocommerce_pay_page_id' );
get_option( 'woocommerce_thanks_page_id' );
get_option( 'woocommerce_myaccount_page_id' );
get_option( 'woocommerce_edit_address_page_id' );
get_option( 'woocommerce_view_order_page_id' );
get_option( 'woocommerce_terms_page_id' );
@barbareshet
barbareshet / woocommerce_events.md
Created May 31, 2023 05:51 — forked from mpdevcl/woocommerce_events.md
WooCommerce JS Events

WooCommerce JS Events

Source

Checkout

$( document.body ).trigger( 'init_checkout' );
$( document.body ).trigger( 'payment_method_selected' );
$( document.body ).trigger( 'update_checkout' );
$( document.body ).trigger( 'updated_checkout' );
$( document.body ).trigger( 'checkout_error' );
@barbareshet
barbareshet / wp-config.php
Created January 10, 2023 09:52 — forked from lukecav/wp-config.php
Exclude options data from being caching in Redis using the Redis Object Cache plugin
define( 'WP_REDIS_IGNORED_GROUPS', [ 'options' ]);
@barbareshet
barbareshet / class-rcp-payment-gateway.php
Created December 22, 2022 13:24 — forked from ashleyfae/class-rcp-payment-gateway.php
RCP payment gateway base class
<?php
/**
* Payment Gateway Base Class
*
* You can extend this class to add support for a custom gateway.
* @link http://docs.restrictcontentpro.com/article/1695-payment-gateway-api
*
* @package Restrict Content Pro
* @subpackage Classes/Gateway
* @copyright Copyright (c) 2017, Pippin Williamson
@barbareshet
barbareshet / functions.php
Last active December 7, 2022 20:02 — forked from Anatal/functions.php
WP Ajax
function hello_elementor_child_enqueue_scripts() {
wp_enqueue_style(
'hello-elementor-child-style',
get_stylesheet_directory_uri() . '/style.css',
[
'hello-elementor-theme-style',
],
'1.0.0'
);
@barbareshet
barbareshet / wc_order_status_changes.php
Created August 23, 2022 09:17 — forked from abegit/wc_order_status_changes.php
WooCommerce Hooks for Order Status Changes
function mysite_pending($order_id) {
error_log("$order_id set to PENDING", 0);
}
function mysite_failed($order_id) {
error_log("$order_id set to FAILED", 0);
}
function mysite_hold($order_id) {
error_log("$order_id set to ON HOLD", 0);
}
function mysite_processing($order_id) {
@barbareshet
barbareshet / enqueue.php
Created August 22, 2022 16:28 — forked from ricardobrg/enqueue.php
Enqueue scripts in WordPress with defer or async
<?php
// This code is based in Mathew Horne blog post: https://matthewhorne.me/defer-async-wordpress-scripts/
//function to add async attribute
function add_async_attribute($tag, $handle) {
$scripts_to_async = array('my-js-handle-async', 'another-handle-async');
//check if this script is in the array
if (in_array($handle, $scripts_to_async)){
//return with async
return str_replace(' src', ' async="async" src', $tag);
@barbareshet
barbareshet / DNS Prefetch domains
Created August 15, 2022 11:10 — forked from lukecav/DNS Prefetch domains
WP Rocket - Advanced Options Prefetch DNS requests examples
//maps.googleapis.com
//maps.gstatic.com
//fonts.googleapis.com
//fonts.gstatic.com
//ajax.googleapis.com
//apis.google.com
//google-analytics.com
//www.google-analytics.com
//ssl.google-analytics.com
//youtube.com
@barbareshet
barbareshet / learnpress-enroll-status.php
Created June 8, 2022 12:04 — forked from wpacademy/learnpress-enroll-status.php
Check if user has enrolled into any course at your LearnPress website.
<?php
/*
* Function to check if given user is enrolled into any course.
*/
function wpac_check_enrolled_user($user_id){
if (is_numeric($user_id)) {
//Global WordPress DB object
global $wpdb;