• Resolved breeakpoint

    (@breeakpoint)


    Getting the following errors. WordPress 5.0.3 and plugin version 8.4.06

    [10-Jan-2019 21:27:21 UTC] PHP Notice:  Object of class WC_DateTime could not be converted to int in C:\xampp\htdocs\wp-content\plugins\squirrly-seo\models\services\OpenGraph.php on line 164
    [10-Jan-2019 21:27:21 UTC] PHP Notice:  Object of class WC_DateTime could not be converted to int in C:\xampp\htdocs\wp-content\plugins\squirrly-seo\models\services\OpenGraph.php on line 168
    [10-Jan-2019 21:27:21 UTC] PHP Warning:  date() expects parameter 2 to be integer, object given in C:\xampp\htdocs\wp-content\plugins\squirrly-seo\models\services\OpenGraph.php on line 169
Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter breeakpoint

    (@breeakpoint)

    I think the root cause occurs on line 143 of the mentioned file.

    $sale_price is expected to be an integer, but it is being re-assigned to a date. I don;t think this re-assignment should occur and the line should be removed?

    Line 143: $sale_price = $product->get_date_on_sale_from();

    Plugin Contributor Calin Vingan

    (@calinvingan)

    Hi,

    Thank you for letting us know about this. Please add these lines at the line 144 right after the variables are set.

    if(is_a($sales_price_from, 'WC_DateTime')){
       $sales_price_from = $sales_price_from->getTimestamp();
    }
    if(is_a($sale_price, 'WC_DateTime')){
       $sale_price = $sale_price->getTimestamp();
    }

    It should look like this from line 139:

    if (method_exists($product, 'get_sale_price')) {
        $sale_price = $product->get_sale_price();
        if ($sale_price > 0 && method_exists($product, 'get_date_on_sale_from')) {
            $sales_price_from = $product->get_date_on_sale_from();
            $sale_price = $product->get_date_on_sale_from();
    
            if(is_a($sales_price_from, 'WC_DateTime')){
                $sales_price_from = $sales_price_from->getTimestamp();
            }
            if(is_a($sale_price, 'WC_DateTime')){
                $sale_price = $sale_price->getTimestamp();
            }
        }
    }

    I will add the changes in the next version of the plugin.

    Best regards, Calin

    Thread Starter breeakpoint

    (@breeakpoint)

    Works great, thank you!

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

The topic ‘Getting errors with plugin’ is closed to new replies.