Skip to content

Instantly share code, notes, and snippets.

@tripflex
tripflex / functions.php
Last active August 13, 2023 18:16
Programmatically create a WooCommerce Subscription and associated WooCommerce Order
<?php
public function give_user_subscription( $product, $user_id, $note = '' ){
// First make sure all required functions and classes exist
if( ! function_exists( 'wc_create_order' ) || ! function_exists( 'wcs_create_subscription' ) || ! class_exists( 'WC_Subscriptions_Product' ) ){
return false;
}
$order = wc_create_order( array( 'customer_id' => $user_id ) );
@mattallan
mattallan / add-line-item-product-type-rest-api.php
Last active January 29, 2019 23:32
Add line item product type to orders rest api output
<?php
/**
* Plugin Name: Line item product type in Orders REST API response.
* Plugin URI:
* Description: Display the product type in the line items array returned by WC REST API Orders requests.
* Author: Prospress Inc, Matt Allan
* Author URI: https://prospress.com/
* Version: 1.0
*
* This program is free software: you can redistribute it and/or modify
@r-a-y
r-a-y / bp-disable-translation.php
Created February 15, 2015 18:40
Disable automatic translations by WordPress.org / GlotPress for BuddyPress.
<?php
/*
Plugin Name: BP Disable Auto Translation
Description: Disables automatic translations by WordPress.org / GlotPress for BuddyPress.
Author: r-a-y
License: GPLv2 or later
*/
/**
* Disables automatic translations for BuddyPress.
@etiennetremel
etiennetremel / content-single-product.php
Last active June 27, 2023 00:43
WooCommerce Upsells Upsells as checkbox. When product is deleted from the cart, upsells are also deleted.
<?php
/**
* The template for displaying product content in the single-product.php template
*
* Override this template by copying it to yourtheme/woocommerce/content-single-product.php
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 1.6.4
*/
@ScottPhillips
ScottPhillips / .htaccess
Created February 2, 2012 04:30
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/