Skip to content

Instantly share code, notes, and snippets.

View dwainm's full-sized avatar
💸
WooCommerce Payments https://woocommerce.com/payments/

Dwain Maralack dwainm

💸
WooCommerce Payments https://woocommerce.com/payments/
View GitHub Profile
@dwainm
dwainm / upcomingweeks_mon_to_friday.sh
Created March 7, 2024 10:31
bash script for printing out a list weeks in format (month dd[mon] - month dd[fri])
function upcommingCalendarWeeks(){
for ((j = 1 ; j < 52 ; j++)); do
mondayMonth=$(date -v-Sun -v+${j}w -v+Mon "+%b")
mon=$(date -v-Sun -v+${j}w -v+Mon "+%d")
fridayMonth=$(date -v-Sun -v+${j}w -v+Fri "+%b")
fri=$(date -v-Sun -v+${j}w -v+Fri "+%d")
echo "$mondayMonth $mon - $fridayMonth $fri"
done
}
System status report
Sample:
`
### WordPress Environment ###
Home URL: https://woocommerce.com
Site URL: https://woocommerce.com
WC Version: 3.3.5
https://gist.github.com/dwainm/31fd57407b099bf9a6b35a2b9d85c16b
*** WooCommerce Bookings Changelog ***
2018-05-23 - version 1.11.2
* Update - Privacy policy notification.
* Update - Export/erasure hooks added.
* Update - WC 3.4 compatibility.
2018-04-24 - version 1.11.1
* Fix - Booking Reminder Emails: Same-day Bookings Contain The Text 'tomorrow'.
* Fix - Calendar doesn't load the correct availability for different resources.
@dwainm
dwainm / custom.php
Last active December 1, 2017 12:15
Update WooCommerce Subscription method to PayFast
<?php
update_post_meta( $subscription_id, '_payfast_subscription_token', $token );
update_post_meta( $subscription_id, '_payment_method', 'payfast' );
@dwainm
dwainm / functions.php
Last active November 23, 2017 06:52
Fame Themes OnePress Sensei Wrappers ( integration ) https://www.famethemes.com/themes/onepress
<?php // << make sure to remove this `<?php` if you're copying this into your functions.php
//
// Your code goes below
//
/** Sensei Integration **/
add_action( 'after_setup_theme', 'declare_sensei_support' );
function declare_sensei_support() {
add_theme_support( 'sensei' );
}
@dwainm
dwainm / bookings_test_generator.php
Last active February 18, 2017 22:09
Generate WooCommerce bookings unit tests given a product ID.
<?php
/**
* Bookings
*/
add_action( 'init', function(){
// WC_Stamps_API::get_client();
//add_filter( 'wc_bookings_calendar_default_to_current_date', '__return_false' );
//if ( defined( 'DOING_AJAX' ) || defined( 'DOING_CRON' ) ) return;
//booking_product_to_code_print_meta_booking(9454); die;
@dwainm
dwainm / class-wc-product-booking.php
Created June 10, 2016 15:37
Hide the time blocks that are not available due to resources being booked already.
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class for the booking product type
*/
class WC_Product_Booking extends WC_Product {
private $availability_rules = array();
@dwainm
dwainm / functions.php
Last active November 9, 2015 08:22
Add the code to your functions.php . This will create a notice with a button on the admin learning grading page. This will make sure the questions that you see in grading are the actual question submitted by the user. It is a work around for this bug: https://github.com/woothemes/sensei/issues/803
<?php // do not include this fir line with php as it will break your site, it was only added for styling
add_action('admin_init','sensei_custom_code_reset_questions_asked');
function sensei_custom_code_reset_questions_asked(){
if( ! isset( $_POST['sensei_custom_code_reset_questions_asked'] )
|| ! ( isset( $_POST['sensei_custom_code_reset_questions_asked_nonce'] )
&& wp_verify_nonce( $_POST['sensei_custom_code_reset_questions_asked_nonce'], 'sensei_custom_code_reset_questions_asked_for_user' ) )
){
@dwainm
dwainm / class-woothemes-sensei-list-table.php
Created May 22, 2015 07:26
Updated Sensei WP_List_Table class implementation
<?php
/**
* Base class for displaying a list of items in an ajaxified HTML table.
*
* @since 3.1.0
* @access private
*
* @package WordPress
* @subpackage List_Table
*/