Skip to content

Instantly share code, notes, and snippets.

@PogHallam
PogHallam / AddContact.php
Last active March 4, 2021 09:26
Create contact on Spotler API with 2 custom fields.
We couldn’t find that file to show.
/**
* Given a timestamp, return true if it is a leap year.
*
* @param int $timestamp A unix timestamp.
*
* @return bool
*/
function is_leap_year( int $timestamp ): bool {
function registration_form_add_country_field() {
// Only show if secret arg is in URL.
if ( empty( $_GET['add_field'] ) || $_GET['add_field'] != 1 ) {
return;
}
$form = GFAPI::get_form( TEST_FORM_ID );
$new_field_id = 0;
@PogHallam
PogHallam / payment_method_identifier.php
Created April 4, 2019 15:27
Get the label/id of current payment methods. Use this to avoid issues with differing IDs on local/staging/production. e.g. 'flat_rate:9', 'table_rate:5:5', etc.
$packages = WC()->shipping->get_packages();
foreach ( $packages[0]['rates'] as $key => $shipping_rate ) {
dump( [ $shipping_rate->get_id(), $shipping_rate->get_label() ] );
}