Skip to content

Instantly share code, notes, and snippets.

Tech Skilled techskilled

View GitHub Profile
View Woo Checkout - How to get WooCommerce order details
## Get Your Order ID
$order_id = 232323 // Change to your order Id
$order = wc_get_order( $order_id );
## Get Item Details
$product_name = $item_data['name'];
$product_id = $item_data['product_id'];
$variation_id = $item_data['variation_id'];
$quantity = $item_data['quantity'];
$tax_class = $item_data['tax_class'];
View gist:c7b723f09db96e32609d86a917f74fa4
#Redirect a Single Page
Redirect 301 /oldpage.html http://www.yoursite.com/newpage.html
Redirect 301 /oldpage2.html http://www.yoursite.com/folder/
#Redirect Entire Website
Redirect 301 / http://yournewsite.com/
Redirect 301 / http://yournewsite.com/
View gist:cf1809b71f8701a6599df9e52dcd50e2
/**
* @snippet WooCommerce Single Page - Move Tabs below the add to cart button
* @code https://techskilled.co.uk/snippets/single-page-move-tabs-below-the-add-to-cart-button
* @author https://techskilled.co.uk
*/
function techskilled_move_tabs(){
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_output_product_data_tabs', 70 );
}
@techskilled
techskilled / gist:9e7d0f14cb8cf1c392ce8402127f46cf
Last active Mar 23, 2019
Wordpress Admin - Enable maintenance mode for non-admins
View gist:9e7d0f14cb8cf1c392ce8402127f46cf
/**
* @snippet Wordpress Admin - Enable maintenance mode for non-admins
* @code https://techskilled.co.uk/snippets/admin-enable-maintenance-mode-for-non-admins-2
* @author https://techskilled.co.uk
*/
function wpts_maintenance_mode(){
if(!current_user_can(‘edit_themes’) || !is_user_logged_in()){
wp_die(‘Under Maintenance, please come back soon.’, ‘Under Maintenance – please come back soon.’, array(‘response’ => ‘503’));
}
@techskilled
techskilled / gist:bc0b3ed651d9ea7cc0c746ae6065786c
Last active Mar 23, 2019
Woocommerce - Single Product - Add Content After Add to Cart
View gist:bc0b3ed651d9ea7cc0c746ae6065786c
/**
* @snippet Woocommerce Checkout - Add Secure Logo to Checkout Page
* @code https://techskilled.co.uk/snippets/woocommerce-checkout-add-secure-logo-to-checkout-page
* @author https://techskilled.co.uk
*/
function bbloomer_trust_place_order() {
echo '<img src="https://www.paypalobjects.com/digitalassets/c/website/marketing/na/us/logo-center/9_bdg_secured_by_pp_2line.png" style="margin: 1em auto">';
}
add_action( 'woocommerce_review_order_after_submit', 'bbloomer_trust_place_order' );
@techskilled
techskilled / gist:48bec2fcfc799b38d3a7b0a5f93735cd
Last active Mar 23, 2019
Wordpress Media Snippet - Media - Allow SVG Media Logo Upload
View gist:48bec2fcfc799b38d3a7b0a5f93735cd
/**
* @snippet Wordpress Media Snippet - Media - Allow SVG Media Logo Upload
* @code https://techskilled.co.uk/snippets/wordpress-allow-svg-media-logo-upload-snippet
* @author https://techskilled.co.uk
*/
function ts_mime_types($mimes) {
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
@techskilled
techskilled / gist:e6bd55ce11dbcfaeea87c53e2aae5170
Last active Mar 23, 2019
Woocommerce - Single Product - Add Content After Add to Cart
View gist:e6bd55ce11dbcfaeea87c53e2aae5170
/**
* @snippet Woocommerce - Single Product - Add Content After Add to Cart
* @code https://techskilled.co.uk/snippets/woocommerce-add-content-after-add-to-cart-single-product-page
* @author https://techskilled.co.uk
*/
function show_content_after_add_to_cart() {
echo '<div style="clear: both; padding-top: 20px;"><a style="font-weight: 600;" href="#doit">OR Doing it yourself?</a></div> ';
@techskilled
techskilled / snippets.php
Last active Mar 23, 2019
Woocommerce - Single Product – Edit Only 1 left in stock
View snippets.php
/**
* @snippet single Product - Edit Only 1 left in stock
* @code https://techskilled.co.uk/snippets/woocommerce-edit-only-1-left-in-stock-single-product-page
* @author https://techskilled.co.uk
*/
function techskilled_edit_left_stock( $text, $product ) {
$stock = $product->get_stock_quantity();
if ( $product->is_in_stock() && $product->managing_stock() && $stock <= get_option( 'woocommerce_notify_low_stock_amount' ) ) $text .= '. Get it today to avoid 5+ days restocking delay!';
return $text;
View WooCommerce Add to Cart Button Redirect To Checkout
/**
* Remove Cart Stage
* @see: http://stackoverflow.com/questions/15592633/woocommerce-add-to-cart-button-redirect-to-checkout
*/
add_filter( 'add_to_cart_redirect', 'redirect_to_checkout' );
function redirect_to_checkout() {
global $woocommerce;
$checkout_url = $woocommerce->cart->get_checkout_url();
View DISBALE WP-ADMIN FROM NON ADMIN
/** DISBALE WP-ADMIN FROM NON ADMIN : SOBER MEDIA 13/08/2016 **/
add_action('admin_init', 'no_mo_dashboard');
function no_mo_dashboard() {
$isAjax = (defined('DOING_AJAX') && true === DOING_AJAX) ? true : false;
//if (!current_user_can('manage_options') && $_SERVER['DOING_AJAX'] != '/wp-admin/admin-ajax.php') {
if(!$isAjax) {
if(!current_user_can('administrator')) {
wp_redirect('http://www.example.com/'); exit;
You can’t perform that action at this time.