Syntax error activating snippet
-
Hi,
I set up a snippet to make a change to a section in My Account. It had been working fine, but I noticed an error and realized that the snipped had been deactivated. I’m getting this error message:
We encountered an error activating your snippet, please check the syntax and try again. Error message:
Call to a member function get_downloadable_products() on null
I’m not a programmer, so I’m not sure what this means! The snippet is used to change the wording on the “Downloads” section of My Account. I changed the tab from “Downloads” to “Gift Certificates” and created this snippet to change the message that shows up when no gift certificates are available.
What does the error message mean, and, why did it work for weeks and then suddenly deactivate?
<?php if ( ! defined( 'ABSPATH' ) ) {
exit;
} $downloads = WC()->customer->get_downloadable_products();
$has_downloads = (bool) $downloads; do_action( 'woocommerce_before_account_downloads', $has_downloads ); ?> <?php do_action( 'woocommerce_before_available_downloads' ); ?> <?php do_action( 'woocommerce_available_downloads', $downloads ); ?> <?php do_action( 'woocommerce_after_available_downloads' ); ?> <?php $wp_button_class = wc_wp_theme_get_element_class_name( 'button' ) ? ' ' . wc_wp_theme_get_element_class_name( 'button' ) : ''; wc_print_notice( esc_html__( 'No Gift Certificates available.', 'woocommerce' ) . ' <a class="button wc-forward' . esc_attr( $wp_button_class ) . '" href="' . esc_url( apply_filters( 'woocommerce_return_to_shop_redirect', wc_get_page_permalink( 'shop' ) ) ) . '">' . esc_html__( 'Browse products', 'woocommerce' ) . '</a>', 'notice' ); // phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment ?> <?php do_action( 'woocommerce_after_account_downloads', $has_downloads );Thanks so much!
Nan
- The topic ‘Syntax error activating snippet’ is closed to new replies.