Skip to content

Instantly share code, notes, and snippets.

@Skwerl
Last active June 29, 2020 12:02
Show Gist options
  • Select an option

  • Save Skwerl/eab41da19536cd2f30faf5bf444e0e6a to your computer and use it in GitHub Desktop.

Select an option

Save Skwerl/eab41da19536cd2f30faf5bf444e0e6a to your computer and use it in GitHub Desktop.
<?php
/* Lines 1682-1687, Version 1.5.0 */
if(in_array($f_key,array('sku','price','regular_price','sale_price'))){
$var_id=$item->get_variation_id();
if(!empty($var_id)){
$product=wc_get_product($var_id);
}
}
/* Above sometimes throws an error on line 1683; the call to $item->get_variation_id() */
/* Example: Uncaught Error: Call to a member function get_variation_id() on array in /srv/bindings/a8b6247a21304b008fa97cdeeae108e7/code/wp-content/plugins/woo-salesforce-crm-perks-pro/woo-salesforce-crm-perks-pro.php:1683 */
/* Fix: Use if(method_exists($item, 'get_variation_id')) */
/* i.e.: */
if(in_array($f_key,array('sku','price','regular_price','sale_price'))){
if(method_exists($item,'get_variation_id')){
$var_id=$item->get_variation_id();
}
if(!empty($var_id)){
$product=wc_get_product($var_id);
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment