Skip to content

Instantly share code, notes, and snippets.

View mattallan's full-sized avatar

Matt Allan mattallan

View GitHub Profile
@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;
@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 / 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 / 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 / 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 / pp-research-pixel-code.php
Last active October 26, 2016 03:38
Research Prospress Pixel Tracking on post
<?php
/**
* Plugin Name: Research Prospress Pixel Conversion code
* Description: A plugin to bootup our Facebook Pixels on research.prospress.com
* Author: Prospress
* Author URI: https://research.prospress.com
* Version: 1.0
*/
/**
@mattallan
mattallan / sw-facebook-pixel.php
Last active November 7, 2016 01:57
Small Woorld Facebook Pixel Code
<?php
/**
* Plugin Name: Small Woorld Facebook Pixel Conversion code
* Description: A plugin to bootup our Facebook Pixels on Prospress.com
* Author: Prospress
* Author URI: https://smallwoorld.com/
* Version: 1.0
*/
/**
<?php
/**
* Plugin Name: Prospress.com Facebook Pixel Conversion code
* Description: A plugin to bootup our Facebook Pixels on Prospress.com
* Author: Prospress
* Author URI: http://prospress.com/
* Version: 1.0
*/
/**
@mattallan
mattallan / wc-api-endpoints.md
Last active September 19, 2016 04:10
v2.6 WC-API endpoints testing
Some of these examples require httpie installed: brew install httpie

Subscriptions

/subscriptions/

  • GET
@mattallan
mattallan / disable-pp-rt.php
Last active May 18, 2016 03:46
Force disable PP Reference Transactions
<?php
/**
* Plugin Name: Disable PayPal Reference Transactions
* Plugin URI:
* Description: Force the store to use PP Standard. Helps to test both sides of PayPal :+1:
* Version: 1.0
* Author: Matt Allan
* Author URI: http://prospress.com
* License:
*/