1

I'm trying to grab a specific custom attribute to check to see if a flat fee needs to be added at checkout, but I'm a bit new to php and wordpress so I'm having trouble accessing the attribute. Here is what I have so far:

function find_product_value() {

global $woocommerce,$post,$product;
$print_value = get_post_meta($product->id, 'print', true);
$woocommerce->cart->add_fee( __('Value is', 'woocommerce'), $print_value ); }

add_action( 'woocommerce_cart_calculate_fees', 'find_product_value' );
?>

Right now the fourth line of code is being used to display the value of the attribute, but will add the fee when I'm finished. The third line of code is where I'm having the issue; I found it here: Woocommerce getting custom attributes, however I get and error code of "Trying to get property of non-object". Am I not declaring all my variables, or correctly? Or am I trying to use a mismatching command for my variable?

Community
  • 1
  • 1
gpii
  • 31
  • 4

0 Answers0