• Resolved blackpicnic

    (@blackpicnic)


    Hello Allyson! Great plugin – have been using without issue for a year. Today, I attempted to update Registrations for Woocommerce. Now receiving Fatal error; cannot access website or WP Dashboard at all. Advice to fix? thanks!

    Fatal error: Access level to WC_Product_Registrations::$children must be public (as in class WC_Product_Variable) in /home/eckotours/eckotours.com/wp-content/plugins/registrations-for-woocommerce/includes/class-wc-product-registrations.php on line 14

    Here is the complete code from the file class-wc-product-registrations.php

    <?php
    /**
    * Registration Product Variation Class
    *
    * The registrations product variation class extends the WC_Product_Variation product class
    * to create registrations product variations.
    *
    * @package Registrations for WooCommerce\WC_Product_Registrations
    * @since 1.3
    *
    */
    if ( ! defined( ‘ABSPATH’ ) ) exit; // Exit if accessed directly

    class WC_Product_Registrations extends WC_Product_Variable {
    /**
    * Array of children variation IDs. Determined by children.
    *
    * @var array
    */
    protected $children = array();

    /**
    * Array of visible children variation IDs. Determined by children.
    *
    * @var array
    */
    protected $visible_children = array();

    /**
    * Array of variation attributes IDs. Determined by children.
    *
    * @var array
    */
    protected $variation_attributes = array();

    /**
    * Get internal type.
    *
    * @return string
    */
    public function get_type() {
    return ‘registrations’;
    }

    /**
    * Checks the product type to see if it is either this product’s type or the parent’s
    * product type.
    *
    * @access public
    * @param mixed $type Array or string of types
    * @return bool
    */
    public function is_type( $type ) {
    if ( ‘registrations’ == $type || ( is_array( $type ) && in_array( ‘registrations’, $type ) ) ) {
    return true;
    } else {
    return parent::is_type( $type );
    }
    }

    /**
    * Return the formated schedule of given registration variation by id.
    *
    * @since 1.0.1
    *
    * @access public
    * @param int $variation_id The variation ID to display schedule
    */
    public function registration_schedule( $variation_id ) {
    $start = get_post_meta( $variation_id , ‘_event_start_time’, true );
    $end = get_post_meta( $variation_id , ‘_event_end_time’, true );

    if ( !empty( $start ) && !empty( $end ) ) {
    $schedule = sprintf( __( ‘From %s to %s’ , ‘registrations-for-woocommerce’ ), $start, $end );
    echo $schedule;
    }
    }

    /**
    * Return the formated date of given registration variation by id.
    *
    * @since 1.0.0
    *
    * @param int $variation_id The variation ID to display schedule.
    */
    public function registration_date( $variation_id, $date_format = null ) {
    $date = get_post_meta( $variation_id , ‘attribute_dates’, true );

    if ( !empty( $date ) ) {
    $formated_date = WC_Registrations_Admin::registration_variation_option_name( $date, $date_format );
    echo $formated_date;
    }
    }

    /**
    * Return whic days of week the current registration will occurr.
    *
    * @since 1.0.0
    *
    * @param int $variation_id The variation ID to display schedule
    */
    public function registration_days_of_week( $variation_id ) {
    $date = get_post_meta( $variation_id , ‘attribute_dates’, true );

    if ( !empty( $date ) ) {
    $opt = json_decode( stripslashes( $date ) );

    if ( $opt ) {
    if ( $opt->type == ‘single’ ) {
    echo date_i18n( ‘l’, strtotime( $opt->date ) );
    }
    elseif ( $opt->type == ‘multiple’ ) {

    $date_option = ”;
    $size = count( $opt->dates );

    for ( $i = 0; $i < $size ; $i++ ) {
    if ( $date_option == ” ) {
    $date_option .= date_i18n( ‘l’, strtotime( $opt->dates[ $i ] ) );
    } else {
    $date_option .= ‘, ‘ . date_i18n( ‘l’, strtotime( $opt->dates[ $i ] ) );
    }
    }

    echo $date_option;
    }
    elseif ( $opt->type == ‘range’ ) {
    if ( $week_days = get_post_meta( $variation_id, ‘_week_days’, true ) ) {
    $content = ”;
    $count = 0;

    foreach( $week_days as $day ) {
    if( $count > 0 ) {
    $content .= ‘, ‘;
    }

    switch( $day ) {
    case ‘sunday’: $content .= __( ‘sunday’, ‘registrations-for-woocommerce’ );
    break;
    case ‘monday’: $content .= __( ‘monday’, ‘registrations-for-woocommerce’ );
    break;
    case ‘tuesday’: $content .= __( ‘tuesday’, ‘registrations-for-woocommerce’ );
    break;
    case ‘wednesday’: $content .= __( ‘wednesday’, ‘registrations-for-woocommerce’ );
    break;
    case ‘thursday’: $content .= __( ‘thursday’, ‘registrations-for-woocommerce’ );
    break;
    case ‘friday’: $content .= __( ‘friday’, ‘registrations-for-woocommerce’ );
    break;
    case ‘saturday’: $content .= __( ‘saturday’, ‘registrations-for-woocommerce’ );
    break;
    default:
    }

    $count++;
    }

    echo $content;
    }
    }
    else {
    return $opt;
    }
    }
    }
    }

    /**
    * Sync a variable product with it’s children. These sync functions sync
    * upwards (from child to parent) when the variation is saved.
    *
    * @param WC_Product|int $product Product object or ID for which you wish to sync.
    * @param bool $save If true, the prouduct object will be saved to the DB before returning it.
    * @return WC_Product Synced product object.
    */
    public static function sync( $product, $save = true ) {
    if ( ! is_a( $product, ‘WC_Product’ ) ) {
    $product = wc_get_product( $product );
    }
    if ( is_a( $product, ‘WC_Product_Registrations’ ) ) {
    $data_store = WC_Data_Store::load( ‘product-variable’ );
    $data_store->sync_price( $product );
    $data_store->sync_stock_status( $product );
    self::sync_attributes( $product ); // Legacy update of attributes.

    do_action( ‘woocommerce_variable_product_sync_data’, $product );

    if ( $save ) {
    $product->save();
    }

    wc_do_deprecated_action( ‘woocommerce_variable_product_sync’, array( $product->get_id(), $product->get_visible_children() ), ‘3.0’, ‘woocommerce_variable_product_sync_data, woocommerce_new_product or woocommerce_update_product’ );
    }
    return $product;
    }

    /**
    * Sync parent stock status with the status of all children and save.
    *
    * @param WC_Product|int $product Product object or ID for which you wish to sync.
    * @param bool $save If true, the prouduct object will be saved to the DB before returning it.
    * @return WC_Product Synced product object.
    */
    public static function sync_stock_status( $product, $save = true ) {
    if ( ! is_a( $product, ‘WC_Product’ ) ) {
    $product = wc_get_product( $product );
    }
    if ( is_a( $product, ‘WC_Product_Registrations’ ) ) {
    $data_store = WC_Data_Store::load( ‘product-variable’ );
    $data_store->sync_stock_status( $product );

    if ( $save ) {
    $product->save();
    }
    }
    return $product;
    }
    }

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Allyson

    (@allysonsouza)

    Hi @blackpicnic,

    Did you update WooCommerce? Which version of WooCommerce are you using?
    If you have access to the server, can you rename the plugin folder at wp-content/plugins/registrations-for-woocommerce, adding some random character just to deactivate the plugin and reestablish you panel access?

    I’m sorry for the inconvenience.

    • This reply was modified 7 years ago by Allyson.
    Thread Starter blackpicnic

    (@blackpicnic)

    Thank you! I’m back in to my WP panel.

    Yes, I need to update all my WooCommerce plugins. I have the following; in which order should I update them?

    WooCommerce 2.6.14 (update to 3.2.4)
    WooCommerce Checkout Terms Conditions Popup 1.1.3 (update to 1.1.7)
    WooCommerce Stripe Gateway 3.0.7 (update to 3.2.3)
    Registrations for WooCommerce 2.0.1
    Flexible WooCommerce Checkout Field Editor 1.0.0

    Plugin Author Allyson

    (@allysonsouza)

    @blackpicnic I suggest you to update first WooCoommerce, and then the other plugins. Our plugin should work normally with the latest version of WooCommerce. Let me know if it works!

    Thread Starter blackpicnic

    (@blackpicnic)

    Thank you so much for your super-fast support! All is well in Woo-land. Obrigado Allyson!

    Plugin Author Allyson

    (@allysonsouza)

    Great! I’m happy everything is fine ??
    De nada!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Fatal Error on Update’ is closed to new replies.