Woocommerce add Custom Shipping Fee

Use your discretion and adjust the function as you need it. It should make sense when you read the function. It currently sets a shipping fee based on the total cost of the cart. // ADD SHIPPING COST function woo_add_cart_fee() { if...

PHP Start A Session and Set Session Variable

<?php session_start(); if (!isset($_SESSION[‘splash’])) { $_SESSION[‘splash’] = “active”; echo “Session has been started”; }else { echo “Session is currently active”; // $_SESSION[‘splash’] =...

WP_QUERY

Calling your Query While or Foreach While <?php $query = new WP_Query($args); ?> <?php while ( $query->have_posts() ) : the_post(); ?> <div> <?php $query->the_post(); get_template_part( ‘content’, get_post_format() ); ?>...

Start Making A WordPress Plugin From Scratch

This post requires developer discretion. The file names are written as an example for this post. As long as you make sure your files are been linked up correctly, you can name your files whatever you like. There’s loads of comments to help you along the way. You...

Step 1 Adding a Plugin

function my_admin_menu() { $page_title = ‘Clear Stock’; $menu_title = ‘Clear Stock’; $capability = ‘manage_options’; $menu_slug = ‘/clear_stock’; $function = ‘clear_stock’; $icon_url = ”; $position =...

PHP Dates broken down parameters

<?php echo date_default_timezone_set(‘UTC’); /* The terrminology for this function h : 12 hour format H : 24 hour format i : Minutes s : Seconds u : Microseconds a : Lowercasw am or pm l : Full text for the day F : Full text for the month j : Day of the...

WordPress Update meta_value by meta_key

// Clear Stock function clear_current_stock(){ // Declare the $wpdb var global $wpdb; // Run My SQL Query (My Query is setting the meta value for stock to zero) $wpdb->query(“UPDATE wp_postmeta SET meta_value = 0 WHERE meta_key = ‘_stock'”); // Check...

Check User Role ( if statement included )

<?php $user_id = get_current_user_id(); if (!empty($user_id)) { $user = wp_get_current_user(); $role = ( array ) $user->roles; // echo $role[0]; if ($role[0] == ‘free-client’ OR $role[0] == ‘administrator’) { //code here… } }...

PHP Delete Cookie

<?php // set the expiration date to one hour ago setcookie(“user”, “”, time() – 3600); ?> <?php echo “Cookie ‘user’ is deleted.”; ?>

PHP Set Cookie and Retrieve Cookie

<?php $cookie_name = “user”; $cookie_value = “Alex Porter”; setcookie($cookie_name, $cookie_value, time() + (86400 * 30), “/”); ?> <?php if(!isset($_COOKIE[$cookie_name])) { echo “Cookie named ‘” ....

Pin It on Pinterest

Share This