• Resolved webzang

    (@webzang)


    The plugin is causing a conflict and showing code on the product page as follows:

    Uncaught Error: Call to a member function get_meta() on string in /home/ravesfro/public_html/wp-content/plugins/yith-pre-order-for-woocommerce/includes/class-yith-pre-order-product.php on line 69 Call stack: YITH_Pre_Order_Product::get_pre_order_status() wp-content/themes/raves/woocommerce/single-product/add-to-cart/variable.php:28 include('/home/ravesfro/publi...to-cart/variable.php') wp-content/plugins/woocommerce/includes/wc-core-functions.php:346 wc_get_template() wp-content/plugins/woocommerce/includes/wc-template-functions.php:1962 woocommerce_variable_add_to_cart() wp-includes/class-wp-hook.php:324 WP_Hook::apply_filters() wp-includes/class-wp-hook.php:348 WP_Hook::do_action() wp-includes/plugin.php:517 do_action() wp-content/plugins/woocommerce/includes/wc-template-functions.php:1904 woocommerce_template_single_add_to_cart() wp-includes/class-wp-hook.php:324 WP_Hook::apply_filters() wp-includes/class-wp-hook.php:348 WP_Hook::do_action() wp-includes/plugin.php:517 do_action() wp-content/themes/raves/woocommerce/content-single-product.php:80 require('/home/ravesfro/publi...t-single-product.php') wp-includes/template.php:812 load_template() wp-content/plugins/woocommerce/includes/wc-core-functions.php:285 wc_get_template_part() wp-content/themes/raves/woocommerce/single-product.php:29 include('/home/ravesfro/publi...e/single-product.php') wp-includes/template-loader.php:106 require_once('/home/ravesfro/publi.../template-loader.php') wp-blog-header.php:19 require('/home/ravesfro/public_html/wp-blog-header.php') index.php:17

    we have tried switching to a default theme, deactivating other plugins and we have had to deactivate it as it looks so bad on the site.

    Is this a known issue? Is there any patch before I switch to a different plugin?

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

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support Carlos M

    (@cjmora)

    Hi @webzang,
    The problem comes from this file from your “raves” theme:
    wp-content/themes/raves/woocommerce/single-product/add-to-cart/variable.php

    Maybe the problem isn’t related to Pre-Order but a bad practice on this template file within your theme.

    Is it possible to paste here in your next reply the content of the variable.php file, at least the lines surrounding line 28? Just to understand better what is being called there.

    Thread Starter webzang

    (@webzang)

    Hi

    Thanks so much for your quick relpy. here is the first 37 lines from that theme file:

    /**

    • Variable product add to cart
      *
    • This template can be overridden by copying it to yourtheme/woocommerce/single-product/add-to-cart/variable.php.
      *
    • HOWEVER, on occasion WooCommerce will need to update template files and you
    • (the theme developer) will need to copy the new files to your theme to
    • maintain compatibility. We try to do this as little as possible, but it does
    • happen. When this occurs the version of the template file will be bumped and
    • the readme will list any important changes.
      *
    • @see https://docs.woocommerce.com/document/template-structure/
    • @package WooCommerce/Templates
    • @version 3.5.5
      */

    defined( 'ABSPATH' ) || exit;

    global $product;

    $attribute_keys = array_keys( $attributes );

    foreach( $available_variations as $i => $variation ) {
    $id = $variation['variation_id'];
    if ( class_exists( 'YITH_Pre_Order_Product' ) ){
    $pre_order = new YITH_Pre_Order_Product( $id );
    if ( $pre_order->get_pre_order_status() == 'yes') {
    $available_variations[$i]['availability_html'] = '

    Pre-order';
    }
    }
    }

    $variations_json = wp_json_encode( $available_variations );
    $variations_attr = function_exists( 'wc_esc_json' ) ? wc_esc_json( $variations_json ) : _wp_specialchars( $variations_json, ENT_QUOTES, 'UTF-8', true );

    do_action( 'woocommerce_before_add_to_cart_form' );

    Plugin Support Carlos M

    (@cjmora)

    Hi @webzang,
    Indeed, the problem is not from the Pre-Order plugin, but a custom code added to that template that uses functions of the Pre-Order plugin incorrectly.
    To fix the issue, replace this part:

    foreach( $available_variations as $i => $variation ) {
    $id = $variation['variation_id'];
    if ( class_exists( 'YITH_Pre_Order_Product' ) ){
    $pre_order = new YITH_Pre_Order_Product( $id );
    if ( $pre_order->get_pre_order_status() == 'yes') {
    $available_variations[$i]['availability_html'] = 'Pre-order';
    }
    }
    }

    with this:

    if ( class_exists( 'YITH_Pre_Order_Utils' ) ) {
    foreach( $available_variations as $i => $variation ) {
    if ( $variation instanceof WC_Product && YITH_Pre_Order_Utils::is_pre_order_active( $variation ) ) {
    $available_variations[$i]['availability_html'] = 'Pre-order';
    }
    }
    }
    Thread Starter webzang

    (@webzang)

    This worked really well great. is there a way to remove the gap between the “expected” date and variation descriptions? See https://ravesfromthegrave.com/shop/beneath-strawberry-moons/

    Plugin Support Carlos M

    (@cjmora)

    Hi @webzang,
    A CSS code like this should remove the gap:

    .ywpo_availability_date.pre_order_single-no-auto-format {
    margin-bottom: 0px !important;
    }
    Thread Starter webzang

    (@webzang)

    Thanks so much this fixed it! Much appreciated.

Viewing 6 replies - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.