Skip to content

Instantly share code, notes, and snippets.

@brettshumaker
Created May 31, 2017 20:08
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 brettshumaker/58bdfc6256fd39a6b0ab0e1df1fee568 to your computer and use it in GitHub Desktop.
Save brettshumaker/58bdfc6256fd39a6b0ab0e1df1fee568 to your computer and use it in GitHub Desktop.
Fatal Error on line 1033 hooks-n-filters.php
<?php
add_action( 'woocommerce_subscriptions_updated_users_role', 'st_woocommerce_subscriptions_updated_users_role', 11, 3 );
function st_woocommerce_subscriptions_updated_users_role( $role_new, $user, $role_old ) {
$_pf = new WC_Product_Factory();
if ( 'member_going_in' == $role_new || WC_Subscriptions_Manager::user_has_subscription( $user->ID, '', 'active') ) {
$subscriptions = wcs_get_users_subscriptions($user->ID);
foreach ( $subscriptions as $subscription ) {
$order = new WC_Order( $subscription->get_parent_id() );
$items = $order->get_items();
$first_item = array_shift($items);
$_product = $_pf->get_product($first_item->get_product_id()); // This is line 1033 in my file
$attributes = $_product->get_attributes();
/* -- irrelevant code here -- */
}
/* -- irrelevant code here -- */
} else if ( 'member_going_out' == $role_new ) {
/* -- irrelevant code here -- */
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment