Skip to content

Instantly share code, notes, and snippets.

View mattallan's full-sized avatar

Matt Allan mattallan

  • Australia
View GitHub Profile
@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
@mattallan
mattallan / index.php
Last active December 22, 2016 14:03
Example Pusher Listener
<!DOCTYPE html>
<head>
<title>Pusher Test</title>
<script src="https://js.pusher.com/3.2/pusher.min.js"></script>
<script>
// Enable pusher logging - don't include this in production
Pusher.logToConsole = true;
var pusher = new Pusher('8ffa40e2d51c6786802e');
@mattallan
mattallan / estimate-billing-periods.php
Last active November 21, 2017 03:04
Estimate billing periods between two timestamps (for WCS Resource) + unit tests
<?php
/**
* Estimate the billing periods between two timestamps
*
* @since 1.0
* @param int $from_timestamp
* @param int $to_timestamp
* @param string $billing_period
* @param string $billing_interval
@mattallan
mattallan / headless-chrome.php
Last active October 20, 2022 05:18
Set chrome to be headless in PHP with facebook/php-webdriver
<?php
// inside `webdriver->create()`
$options = new \Facebook\WebDriver\Chrome\ChromeOptions();
$options->addArguments( [ 'headless' ] );
$capabilities->setCapability( \Facebook\WebDriver\Chrome\ChromeOptions::CAPABILITY, $options );
@mattallan
mattallan / wcsg-update-recipient-address-fix.php
Created February 23, 2024 04:17
Woo Subscriptions Gifting - Recipient Address Update Fix
<?php
/**
* Plugin Name: Woo Subscriptions Gifting - Recipient Address Update Fix
* Description: When changing a subscription's address that you have gifted, only update the shipping address. Don't update the gifter's address.
* Author: Matt Allan
* Author URI: https://woocommerce.com/
*/
function wcsg_update_gifted_subscription_shipping_address() {
global $wp;