Skip to content

Instantly share code, notes, and snippets.

@davidsword
Last active February 3, 2018 03:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidsword/941d74c586620fbff693075cb13a6b96 to your computer and use it in GitHub Desktop.
Save davidsword/941d74c586620fbff693075cb13a6b96 to your computer and use it in GitHub Desktop.
<?php
add_action('wc_square_loaded',function(){
if (class_exists('Woocommerce_Square')) {
add_action( 'plugins_loaded', function(){
// get WooCommerce_Square
$wcsm = Woocommerce_Square::instance();
// startup, (aka `Woocommerce_Square::init()` rebuilt)
$wcsm->integration = new WC_Square_Integration();
$wcsm_client = new WC_Square_Client();
$access_token = get_option( 'woocommerce_square_merchant_access_token' );
$wcsm_client->set_access_token( $access_token );
$wcsm_client->set_merchant_id( $wcsm->integration->get_option( 'location' ) );
$wcsm->square_client = $wcsm_client;
$wcsm->square_connect = new WC_Square_Connect( $wcsm_client );
// basic api call
$response = $wcsm_client->request( 'Retrieving Products', 'modifier-lists' );
// output
echo "<pre>".print_r($response,true)."</pre>";
die;
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment