douya7121 2019-07-19 15:07
浏览 42

Woocommerce变量产品,根据选择的一个值自动选择?

The problem is that right now, for each product that has variations, you have to manually selected a product then the dimensions and then the SKU when realistically, once you select the product there is only one option showing in dimensions and one option in the product code (SKU) so these should really manually be selected upon selecting which product you would like

e.g.

Product Name
  1 Door Nest of 1 - 305mm deep
  1 Door Nest of 2 - 305mm deep

Dimension
  (H) 1974 x (W) 305 x (D) 305mm
  (H) 1974 x (W) 610 x (D) 305mm

Code / SKU
  L/305/1/1
  L/305/1/2

Now, if you select the first option then it looks like this

Product Name
  1 Door Nest of 1 - 305mm deep

Dimension
  (H) 1974 x (W) 305 x (D) 305mm

Code / SKU
  L/305/1/1

i.e. it only shows the dimension and sku relating to that product, which is great but I'd like it to automatically select those options and then give the user the price.

I have tried to un-select the option 'Visible on the product page' for the options I don't require to be visible to the user (though they still show and it did nothing)

I have also tried to use javascript to select the second option as there is always a 'Choose option' and then the actual option, but this only seems to work for whichever product I select that the number is set to in this case 2, product 2 would work and none of the others would.

$('select[name="attribute_name"]').on('change', function() {
      $('select[name="attribute_dimensions"] option:eq(2)').attr('selected', 'selected');
      $('select[name="attribute_product-code"] option:eq(2)').attr('selected', 'selected');
   });

I unfortunately don't have any code, it's just the standard WooCommerce plugin as it stands, no custom PHP code.

I would expect when I click a product, and the options have filtered to the selection to just automatically select the remaining two options as detailed above.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
    • ¥20 怎么用dlib库的算法识别小麦病虫害
    • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
    • ¥15 java写代码遇到问题,求帮助
    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?