Skip to content

Instantly share code, notes, and snippets.

View robindevitt's full-sized avatar

Robin Devitt robindevitt

View GitHub Profile
@robindevitt
robindevitt / related-recipes-by-product-tag.php
Last active October 3, 2023 07:45
Related Recipes by product tag
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly ?>
<?php do_action( 'wpo_wcpdf_before_document', $this->get_type(), $this->order ); ?>
<table class="head container">
<tr>
<td class="header">
<?php
if ( $this->has_header_logo() ) {
do_action( 'wpo_wcpdf_before_shop_logo', $this->get_type(), $this->order );
@robindevitt
robindevitt / php-warnings.php
Last active January 5, 2023 07:28
Warnings when running PHP_CodeSniffer
FILE: https://github.com/googleapis/google-api-php-client-services/blob/main/src/GoogleAnalyticsAdmin/Resource/PropertiesDataStreamsMeasurementProtocolSecrets.php
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
18 | WARNING | 'resource' is a soft reserved keyword as of PHP version 7.0 and should not be used to name a class, interface or trait or as part of a namespace (T_NAMESPACE)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
FILE: https://github.com/googleapis/google-api-php-client-services/blob/main/src/GoogleAnalyticsAdmin/Resource/PropertiesConversion
<?php
// Display a custom text under cart item name in cart page
add_action( 'woocommerce_before_calculate_totals', 'name_on_cart_item', 10, 1 );
function name_on_cart_item ( $cart ) {
if ( is_admin() && ! defined( 'DOING_AJAX' ) )
return;
<?php
function action__product_stock_change( $continue, $post_id, $data, $import_id ) {
$firstImportId = 10;
$supplierPrefix = "A-";
$secondImportId = 20;
// Set the input ID
if ( $import_id === $firstImportId ) {
@robindevitt
robindevitt / class-wc-gateway-payfast.php
Last active March 18, 2022 17:00
Plugin Suggested changes to woocommerce-payfast-gateway/includes/class-wc-gateway-payfast.php
<?php
/**
* PayFast Payment Gateway
*
* Provides a PayFast Payment Gateway.
*
* @class woocommerce_payfast
* @package WooCommerce
* @category Payment Gateways
* @author WooCommerce
add_action ('init', 'disable_store_ordering');
// Disable Cart, Checkout, Add Cart
function disable_store_ordering() {
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
remove_action( 'woocommerce_proceed_to_checkout', 'woocommerce_button_proceed_to_checkout', 20 );
remove_action( 'woocommerce_checkout_order_review', 'woocommerce_checkout_payment', 20 );
add_action( 'woocommerce_before_main_content', 'wc_shop_disable', 5 );
add_action( 'woocommerce_before_cart', 'wc_shop_disable', 5 );
<?php
/*
* Create order dynamically
*/
add_action( 'woocommerce_before_checkout_form', 'create_order' );
function create_order() {
global $woocommerce;
select
p.ID as order_id,
p.post_date,
max( CASE WHEN pm.meta_key = '_order_total' and p.ID = pm.post_id THEN pm.meta_value END ) as order_total,
max( CASE WHEN pm.meta_key = '_customer_user' and p.ID = pm.post_id THEN pm.meta_value END ) as user_id,
us.user_registered,
if( us.user_registered < '2019-01-01', 'returning', 'new' ) as user_type
from
wp_posts p
<?php
$terms = get_field( 'blog_category_tax' );
foreach ( $terms as $term ):?>
<div class="termWrapper">
<h1><?php echo get_cat_name( $term );?></h1>
<div class="featured_posts">
<?php
$args = array(
'numberposts' => 3
'category' => $term,