Skip to content

Instantly share code, notes, and snippets.

View matthijs166's full-sized avatar

Matthijs Knigge matthijs166

View GitHub Profile
@matthijs166
matthijs166 / empty card
Created October 24, 2017 09:03
card empty for woocommerce
if( is_cart() && WC()->cart->cart_contents_count == 0){
wp_safe_redirect( get_permalink( woocommerce_get_page_id( 'shop' ) ) );
}
@matthijs166
matthijs166 / empty card
Last active October 24, 2017 13:24
Empty the woocomerce card
$woocommerce->cart->empty_cart();
@matthijs166
matthijs166 / get all info of a orde
Created October 24, 2017 15:06
get all info of a orde woocommerce
// Get an instance of the WC_Order object
$order = wc_get_order( $order_id );
$order_data = $order->get_data(); // The Order data
$order_id = $order_data['id'];
$order_parent_id = $order_data['parent_id'];
$order_status = $order_data['status'];
$order_currency = $order_data['currency'];
$order_version = $order_data['version'];
@matthijs166
matthijs166 / pritty array
Last active January 13, 2018 18:48
output a array visual array json enz pre
print("<pre>".print_r($customer_orders,true)."</pre>");
header('Location: '.$newURL);
die();
@matthijs166
matthijs166 / seed shufle
Created October 27, 2017 12:53
shuffle a array with a seed
//randomnizer with seed
function fyshuffle(&$items,$seedstring) {
if (!$seedstring) {
$seedval = time();
} else {
if (is_numeric($seedstring)) {
$seedval = $seedstring;
} else {
$seedval = crc32($seedstring);
}
@matthijs166
matthijs166 / check db table wordpress
Created October 31, 2017 13:08
check in wordpress if db exist
<?php
include '../../../../wp-load.php';
global $wpdb;
$table_name = "wp_posts";
if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $table_name) {
//Your code here
}
?>
@matthijs166
matthijs166 / find parameters in url
Created November 3, 2017 12:30
Strip parameters from url javascript
// Get parameters out of the url
function getQueryVariable(variable){
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if(pair[0] == variable){return pair[1];}
}
return(false);
}
@matthijs166
matthijs166 / get img futured
Created November 7, 2017 22:00
get img futured
the_post_thumbnail_url();
@matthijs166
matthijs166 / remove admin bar wordpress
Last active November 13, 2017 13:25
remove admin bar wordpress
add_action('get_header', 'remove_admin_login_header');
function remove_admin_login_header() {
remove_action('wp_head', '_admin_bar_bump_cb');
}