Skip to content

Instantly share code, notes, and snippets.

@arobbins
Last active January 23, 2018 17:56
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 arobbins/aedbe31bd4a24a740c48b003ff17381d to your computer and use it in GitHub Desktop.
Save arobbins/aedbe31bd4a24a740c48b003ff17381d to your computer and use it in GitHub Desktop.
Custom order data example - Order attributes filter
<?php
/*
Step 3. Saves any dynamic session variables to the Shopify order. Fires once the user clicks the checkout button.
*/
function namespace_cart_checkout_attrs() {
// Gain access to the global $_SESSION variable
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
// Check to make sure our unique Session variable exists first
if ( isset($_SESSION['dynamic_values']) && $_SESSION['dynamic_values'] ) {
return $_SESSION['dynamic_values'];
}
}
add_filter('wps_cart_checkout_attrs', 'namespace_cart_checkout_attrs');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment