Skip to content

Instantly share code, notes, and snippets.

View growdev's full-sized avatar
😎
Future's so bright...

Daniel Espinoza growdev

😎
Future's so bright...
View GitHub Profile
@growdev
growdev / functions.php
Created April 22, 2020 19:41
Toolbox for WC Subscriptions: Add this to theme functions file to allow manual renewal payment gateways to skip and set date.
<?php
/**
* Remove the check for if a payment gateway supports "Date change"
*/
remove_filter( 'wcs_view_subscription_actions', 'Javorszky\\Toolbox\\remove_actions', 20 );
/**
* Allow date changes on subscriptions that are manual
* @param $subscription
* @return string
@growdev
growdev / functions.php
Created April 16, 2020 15:34
Add product types to front end of site.
<?php
/**
* Add the booking product and accommodation product type to the list on frontend of site.
*/
function sp_add_post_types( $types ) {
$types['booking'] = __('Bookable product', 'woocommerce-bookings');
$types['accommodation-booking'] = __('Accommodation product', 'woocommerce-accommodation-bookings');
return $types;
}
@growdev
growdev / functions.php
Last active February 3, 2022 01:48
Remove select intervals and periods from the Edit Subscription page of Toolbox for WC Subscriptions
<?php
/**
* Modify the intervals offered by Toolbox for WC Subscriptions.
*
* @param array $intervals
* @param WC_Subscription $subscription
* @return mixed
*/
function sp_modify_intervals( $intervals, $subscription ) {
@growdev
growdev / cart.php
Created September 12, 2019 02:48
Quick plugin to show items that are in WooCommerce cart.
<?php
/**
* Plugin Name: Show Cart
* Plugin URI: https://growdevelopment.com
* Description: Show the cart contents
* Version: 1.0.0
* Author: Grow Development
*/
@growdev
growdev / remove_add_address_button.php
Last active February 3, 2022 02:26
Remove the add address button from the My Account page when using WooCommerce Multiple Shipping Addresses
<?php
add_action( 'init', 'wcmsa_remove_action', 10 );
function wcmsa_remove_action() {
remove_action( 'woocommerce_after_my_account', array( WC_Multiple_Shipping_Addresses()->account, 'add_address_button' ) );
}
@growdev
growdev / remove_wc_data.sql
Last active February 3, 2022 01:52
Remove WooCommerce orders, subscriptions, non admin users
# GET number of orders
select count(*)from wp_posts where post_type = 'shop_order';
# DELETE ORDER DATA FROM POSTMETA TABLE
delete from wp_postmeta where post_id in (select ID from wp_posts where post_type = 'shop_order');
# DELETE ORDER DATA FROM POSTS TABLE
delete from wp_posts where post_type = 'shop_order';
@growdev
growdev / ordercomplete.php
Created January 9, 2018 14:46
set orders to complete
<?php
add_filter( 'woocommerce_payment_complete_order_status', 'growdev_order_payment_complete_order_status', 10, 2 );
function growdev_order_payment_complete_order_status( $order_status, $order_id ) {
$order = wc_get_order( $order_id );
if ( 'processing' == $order_status &&
( 'pending' == $order->status ) ) {
@growdev
growdev / redirect.php
Created October 9, 2017 14:35
redirect from course page if not logged in
<?php
function convertkit_page_template_redirect()
{
if( is_page( 'elements-one' ) && ! is_user_logged_in() )
{
$location = get_site_url() . '/courses/login/?redirect=' . get_permalink( $post->ID );
wp_redirect( $location );
die;
@growdev
growdev / sensei_hooks.php
Last active October 2, 2017 21:27
Hook into Sensei start and end course.
<?php
/**
* Hook in and do an action when a user starts a course.
* This works for WooCommerce purchased courses and free courses.
*/
add_filter( 'sensei_user_course_start', 'convertkit_sensei_user_course_start', 10, 2 );
function convertkit_sensei_user_course_start( $user_id, $course_id ) {
if ( $user_id ) {
$user = get_userdata( $user_id );
@growdev
growdev / ck_subscribe.php
Created May 22, 2017 16:30
Setup CK API and Subscribe customer to Form
<?php
$options = get_option( '_wp_convertkit_settings' );
$api_key = $options && array_key_exists( 'api_key', $options) ? $options['api_key'] : null;
$api_secret = $options && array_key_exists( 'api_secret', $ptions) ? $options['api_secret'] : null;
$debug = $options && array_key_exists( 'debug', $options) ? $options['debug'] : null;
$api = new ConvertKitAPI( $api_key,$api_secret,$debug );
$form_id = '11111';