唯一产品URL的WP电子商务修复程序

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了唯一产品URL的WP电子商务修复程序相关的知识,希望对你有一定的参考价值。

This snippet of code added to line 1404 of wpsc_query.php finds a single product by the product url AND category its in. The default is to only look up a product by its url only, not including the category, meaning you can't have a product in more than one category with the same name.
  1. // ATD 22.DeireadhFomhair.2010 - find a unique product if it has the same product url as something else
  2. $page_url = $_SERVER['REQUEST_URI'];
  3. $product_url = $this->query_vars['product_url_name'];
  4. $products_url = get_option('product_list_url');
  5. $siteurl = get_option('siteurl');
  6. $products_url = str_replace($siteurl, "", $products_url);
  7. $products_url = str_replace('/', '/', $products_url);
  8. if (preg_match("/$products_url/(.*)/$product_url/", $page_url, $matches)) {
  9. $category_url = $matches[1];
  10. $product_id = $wpdb->get_var("SELECT pm.`product_id` FROM `".WPSC_TABLE_PRODUCTMETA."` pm, `".WPSC_TABLE_PRODUCT_CATEGORIES."` pc, `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."` ca WHERE `meta_key` IN ( 'url_name' ) AND `meta_value` IN ( '".stripslashes($this->query_vars['product_url_name'])."' ) AND pc.id = ca.category_id AND pm.product_id = ca.product_id AND pc.`nice-name` = '".stripslashes($category_url)."'");
  11. }

以上是关于唯一产品URL的WP电子商务修复程序的主要内容,如果未能解决你的问题,请参考以下文章

WooCommerce REST API产品图像相对URL问题

如何获取 Woocommerce 产品库图片 URL? [关闭]

插件如何在WordPress中劫持URL? [关闭]

建立电子商务商店(不在WP上)

ZEALER的介绍

商城产品如何应对多个客户不同的需求修改并发布对应客户的文件