Skip to content

Instantly share code, notes, and snippets.

@mrgarry043
mrgarry043 / functions.php
Created February 11, 2019 05:24
user role
add_action( 'woocommerce_order_status_completed', 'wpglorify_change_role_on_purchase' );
function wpglorify_change_role_on_purchase( $order_id ) {
// get order object and items
$order = new WC_Order( $order_id );
$items = $order->get_items();
$product_id = 56; // that's a specific product ID
@mrgarry043
mrgarry043 / functions.php
Last active December 28, 2018 08:31
Move add to cart and variations about description
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 15 );
// Try this to move only varations
remove_action( 'woocommerce_single_variation', 'woocommerce_single_variation', 10 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_single_variation', 15 );
@mrgarry043
mrgarry043 / htaccess
Created September 25, 2018 06:57
Disable xmlprc
# Block WordPress xmlrpc.php requests
<Files xmlrpc.php>
order allow,deny
deny from all
</Files>
@mrgarry043
mrgarry043 / functions.php
Last active July 16, 2017 06:35
Hide Coupon on checkout page if a coupon is already applied
<?php
/*
* source: https://wpglorify.com/?p=3846
* Hide coupon notice on the checkout page if a coupon has been applied in cart
*/
add_filter( 'woocommerce_coupons_enabled', 'woocommerce_coupons_enabled_checkout' );
function woocommerce_coupons_enabled_checkout( $coupons_enabled ) {
global $woocommerce;
@mrgarry043
mrgarry043 / functions.php
Created June 22, 2017 17:28
Move the title and star ratings on right side above product image
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_title', 5);
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_rating', 10);
add_action( 'woocommerce_before_single_product_summary', 'woocommerce_template_single_title', 5 );
add_action( 'woocommerce_before_single_product_summary', 'woocommerce_template_single_rating', 4);
@mrgarry043
mrgarry043 / function.php
Created June 5, 2017 04:33
Deny Checkout if User Has Pending Orders in WooCommerce
/**
* @snippet Deny Checkout to User With Pending Orders | WooCommerce
* @sourcecode https://wpglorify.com/?p=1952
* @author Garry Singh
* @testedwith WooCommerce 3.0.7
*/
add_action('woocommerce_after_checkout_validation', 'wpglorify_deny_checkout_user_pending_orders');
function wpglorify_deny_checkout_user_pending_orders( $posted ) {