Skip to content

Instantly share code, notes, and snippets.

View dvdmierden's full-sized avatar

dvdmierden dvdmierden

View GitHub Profile
/**
* Get the discount details of given product with custom price
* @param $price float/integer
* @param $product object (Product object Example: wc_get_product($product_id))
* @param $quantity int
* @param $custom_price float/integer (0 for calculate discount from product price)
* @param $return_details string (Default value 'discounted_price' accepted values = 'discounted_price','all')
* @param $manual_request boolean (Default value false: pass this as true for get discount even if there is no item in cart)
* @param $is_cart boolean (Default value true)
* @return array|float|int - is product has no discounts, returns $price;else return array of discount details based on $return_details
@dvdmierden
dvdmierden / Convert Custom Taxonomy to Custom Post Type
Created April 5, 2022 13:38 — forked from Strap1/Convert Custom Taxonomy to Custom Post Type
A very hacky and quick way to transfer a Custom Taxonomy to Custom Post Type and transfer associated metadata to Custom Meta Fields. Note: You can use this if it fits your needs, but it is custom to my set up. Use in a testing environment. It's a plugin with no interface, runs on activation and depending on the amount of data, may hit PHP timeou…
<?php
/*
Plugin Name: Convert Custom Taxonomy to Custom Post Type
Plugin URI: N/A
Description: A plugin to convert a Custom Taxonomy to a Custom Post Type and transfer associated metadata.
Version: 0.1
Author: Strap1
Author URI: http:/www.hiphopinenglish.com
/** Convert Taxonomy '%name%' to CPT '%name%' **/