Skip to content

Instantly share code, notes, and snippets.

View mattiasghodsian's full-sized avatar
🏠
Working from home

mattiasghodsian

🏠
Working from home
View GitHub Profile
@mattiasghodsian
mattiasghodsian / wc-kco-validate-customer-age-modded.php
Last active April 28, 2023 08:39
Update code snippet of wc-kco-validate-customer-age.php to only accept purchases from people over 18 years
<?php
/**
* Title: WooCommerce - Klarna payment gateway (Modded)
* Author Niklas Hogefjord
* Editor: Mattias Ghodsian
* Description: Only accept purchases from customer over 18 years of age.
* Source: https://gist.github.com/NiklasHogefjord/07e60a4f08799c3cfdb0870fb5481f71
* Klarna: https://developers.klarna.com/en/se/kco-v2/checkout-api
* Donate a cup of coffee: https://www.buymeacoffee.com/mattiasghodsian
**/
@mattiasghodsian
mattiasghodsian / woocommerce-group-products.php
Last active April 28, 2023 08:39
Group simple/variations and group all variations that had same parent
/**
* Title: Group simple/variations
* Author Mattias Ghodsian
* Description: Group simple/variations and group all variations that had same parent
* Donate a cup of coffee: https://www.buymeacoffee.com/mattiasghodsian
**/
function wooGroupProducts(){
$args = array( 'post_type' => 'product', 'posts_per_page' => -1 );
$loop = new WP_Query( $args );
<?php
/**
* Title: PRO Ladder
* Author: Mattias Ghodsian
* Description: Get ladder data as array from http://pokemon-revolution-online.net
* Donate a cup of coffee: https://www.buymeacoffee.com/mattiasghodsian
**/
class PROLadder
{
private $url = "http://pokemon-revolution-online.net/ladder.php";
@mattiasghodsian
mattiasghodsian / getProductIDBySku
Last active April 28, 2023 08:39
get woocommerce product ID by sku
/**
* Title: getProductIDBySku
* Author: Mattias Ghodsian
* Description: get woocommerce product ID by sku
* Donate a cup of coffee: https://www.buymeacoffee.com/mattiasghodsian
**/
Public function getProductIDBySku( $sku )
{
if (empty($sku)) { return false; }
global $wpdb;
@mattiasghodsian
mattiasghodsian / runner.php
Last active April 28, 2023 08:39
Run functions from array
<?php
/**
* Title: Runner
* Author: Mattias Ghodsian
* Description: Run given functions from array
* Donate a cup of coffee: https://www.buymeacoffee.com/mattiasghodsian
* Donate Eth: 0xBBB96204E45D11C9799c6B12E6eE6F0d4A071Ef5
**/
class Runner
{
@mattiasghodsian
mattiasghodsian / functions.php
Last active April 28, 2023 08:39
Wordpress - Make widgets inside widget area collapse for the Front-end user
<?php
/**
* Title: Widgets collapse for Front-end user
* Author Mattias Ghodsian
* Description: Make widgets inside widget area collapse for the Front-end user
* Donate a cup of coffee: https://www.buymeacoffee.com/mattiasghodsian
* Donate Eth: 0xBBB96204E45D11C9799c6B12E6eE6F0d4A071Ef5
**/
// register widget area
@mattiasghodsian
mattiasghodsian / functions.php
Last active April 28, 2023 08:38
Woocommerce Get product attributes
/**
* Title: Woocommerce Get product attributes
* Author: Mattias Ghodsian
* Description: Get product attributes in a simple way (array)
* Donate a cup of coffee: https://www.buymeacoffee.com/mattiasghodsian
* Donate Eth: 0xBBB96204E45D11C9799c6B12E6eE6F0d4A071Ef5
*
* @param integer $postID
* return array
**/
@mattiasghodsian
mattiasghodsian / functions.php
Last active April 28, 2023 08:38
Wordpress Get taxonomy and associated options & "fields"
/**
* Title: Wordpress Get Taxonomy
* Author: Mattias Ghodsian
* Description: Wordpress Get taxonomy and assosiated options & "fields"
* Donate a cup of coffee: https://www.buymeacoffee.com/mattiasghodsian
* Donate Eth: 0xBBB96204E45D11C9799c6B12E6eE6F0d4A071Ef5
*
* @param boolean $getCurrent get current set "brand" and not list
* @param string $taxonomy taxonomy
* @param boolean $hide_empty hide empty terms
@mattiasghodsian
mattiasghodsian / functions.php
Last active April 28, 2023 08:38
Woocommerce Show price only for logged-in users
/**
* Title: Woocommerce Show price only for logged-in users
* Author: Mattias Ghodsian
* Description: Woocommerce Show price only for logged-in users
* Donate a cup of coffee: https://www.buymeacoffee.com/mattiasghodsian
* Donate Eth: 0xBBB96204E45D11C9799c6B12E6eE6F0d4A071Ef5
*
* @param integer $price
* @param array $product
* return integer
@mattiasghodsian
mattiasghodsian / functions.php
Last active April 28, 2023 08:38
[Wordpress] Show/hide content with shortcodes
/**
* Title: Shortcode Logged in
* Author: Mattias Ghodsian
* Description: Shortcodes that works like if statments
* Donate a cup of coffee: https://www.buymeacoffee.com/mattiasghodsian
* Donate Eth: 0xBBB96204E45D11C9799c6B12E6eE6F0d4A071Ef5
**/
// If logged in
function loggedincontent( $atts , $content)