Woocommerce - 如何链接到产品变化? [英] Woocommerce - How To Link to Product Variation?

查看:25
本文介绍了Woocommerce - 如何链接到产品变化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试找到一种方法来链接到特定产品变体.

I am trying to find a way to have a link to a specific product variation.

我以为我已经用这个插件解决了...https://wordpress.org/plugins/woocommerce-direct-variation-link/

I thought I had it solved with this plugin... https://wordpress.org/plugins/woocommerce-direct-variation-link/

但是,我有 2 个单词的产品属性名称并且似乎无法使用它?我把_, -, &和 + 在 2 个词之间但不去.

However the I have 2 word product attribute names and can't seem to get it to work? I put _, -, & and + between the 2 words but not go.

这是文档...在我的情况下,我将使用颜色样式"而不仅仅是颜色"mysite.com/product/happy-ninja/?color=blue

Here is the doc...In my case I would have "color style" instead of just "color" mysite.com/product/happy-ninja/?color=blue

mysite.com/product/happy-ninja/?color=blue&size=small(其他变体应以&"分隔)

mysite.com/product/happy-ninja/?color=blue&size=small (additional variations should be separated by '&')

mysite.com/product/happy-ninja/?color=blue+green(其中变化值为蓝绿色",空格替换为+")

mysite.com/product/happy-ninja/?color=blue+green (where the variation value is "Blue Green" with the space replaced by a '+')

推荐答案

在最后一张海报之前,我无法让他的代码正常工作,但我确实发现 WooCommerce 大部分时间为购物车生成这些:

Further to the last poster, I couldn't get his code to work properly, but I did discover that WooCommerce generates these for the Cart most of the time:

  1. 亲自访问变体产品
  2. 向购物车添加变体
  3. 打开您的购物车并将鼠标悬停在该项目上 --> 状态栏中的链接(或右键单击 > 复制链接地址)是它!

它应该有这样的后缀:http://website.com/product/product-name/?attribute_colours=Grey

请注意,colours 是小写的,因为它是 slug,而 Grey 是变体的实际名称.

Note that colours is lowercase because it's the slug while Grey is the actual name for the Variation.

对于变体名称中的空格,请使用 + 代替空格.

For spaces in your Variation name, use a + instead of the space.

对于选择多个变体属性,我相信您可以从 & 开始,然后再次吐出 ?attribute_[slug]=Variation.

For selecting multiple variation attributes, I believe you can just start with & and spit the ?attribute_[slug]=Variation again.

这篇关于Woocommerce - 如何链接到产品变化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆