【问题标题】:Remove Sale Price from Google Content API for Shopping using PHP使用 PHP 从 Google Content API for Shopping 中删除销售价格
【发布时间】:2023-03-07 00:09:01
【问题描述】:

我可以通过 Google Content API for Shopping 使用 PHP 语言在我的 Google Merchant Feed 中更新(更改为其他价格产品销售价格。 p>

示例。 40% 折扣的产品(原价 = 100.00 欧元,售价 = 60.00 欧元):

$product = new Google_Service_ShoppingContent_Product();
$product->setOfferId($myProductId);
$product->setContentLanguage($idData[1]);
$product->setTargetCountry($idData[2]);
$product->setChannel($idData[0]);

$price = new Google_Service_ShoppingContent_Price();
$price->setValue(100.00);
$price->setCurrency('EUR');

$product->setPrice($price);

$salePrice = new Google_Service_ShoppingContent_Price();
$salePrice->setValue(60.00);
$salePrice->setCurrency('EUR');

$product->setSalePrice($salePrice);

我无法取消此折扣,我希望我的产品最终价格再次为 100.00 欧元。我试过了:

$product->setSalePrice(NULL);

但我遇到了一个致命错误:

参数 1 传递给 Google_Service_ShoppingContent_Product::setSalePrice() 必须是 Google_Service_ShoppingContent_Price 的实例

我也尝试将值设置为 0

$salePrice = new Google_Service_ShoppingContent_Price();
$salePrice->setValue(0.00);
$salePrice->setCurrency('EUR');

但 Google 不同意我的提议。

我该怎么做?

提前致谢

【问题讨论】:

    标签: php google-api google-api-php-client google-shopping-api google-content-api


    【解决方案1】:

    只需将销售价格的生效日期设置为过去,如下所示:

    $saleStartDate = date(DateTime::ISO8601, strtotime('-5 days'));
    $saleEndDate = date(DateTime::ISO8601, strtotime('-1 day'));
    $product->setSalePriceEffectiveDate($saleStartDate . '/' . $saleEndDate);
    

    没试过,但希望能用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-04-12
      • 2014-08-26
      • 1970-01-01
      • 2017-03-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多