标签: variations

替换所有出现的某些字符并获得所有变化

我有一个单词,我需要用星号替换某个字符,但我需要从这个单词中获取所有替换的变体.例如.我想在星号中用星号替换字符'e':

String word = telephone;
Run Code Online (Sandbox Code Playgroud)

但要获得此列表:

List of words = [t*lephone, tel*phone, telephon*, t*l*phone, t*lephon*, tel*phon*, t*l*phon*];
Run Code Online (Sandbox Code Playgroud)

在Java中有快速的方法吗?

java string replace variations

4
推荐指数
1
解决办法
279
查看次数

可变产品选择器:获取实时选定值

在WooCommerce中,使用以下代码在简单和变量产品中的产品价格之后添加自定义标签:

add_filter('woocommerce_variation_price_html','prices_custom_labels', 10, 2    );
add_filter('woocommerce_price_html','prices_custom_labels', 10, 2 );
function prices_custom_labels( $price, $product ){

    // Set HERE your custom labels names
    $per_dozen = ' '. __('per dozen', 'woocommerce' );
    $per_case = ' '. __('per case (20 dozens)', 'woocommerce' );


    // 1) Variable products
    if ($product->product_type != 'simple' && $product->variation_id ) {

        // Getting the array of existing attributes values for a variation
        $variation_attribute_value = $product->variation_data;
        // Here we keep only the last value in this array
        $last_variation_attribute_slug_value = ' ' …
Run Code Online (Sandbox Code Playgroud)

php wordpress jquery variations woocommerce

4
推荐指数
1
解决办法
2428
查看次数

隐藏WooCommerce 3+中购物车商品标题的变体信息

自从我们升级到Woocommerce第3版以来,我们的订单确认显示了包含变化细节的大量标题.我不喜欢它看起来如何,它打破了一些定制插件的一些重要功能.

参考:订单名称显示自更新到WC版本3以来的变化

有一个过滤器可用于禁用在woocommerce_product_variation_title_include_attribute_name我所理解的标题中显示的数据.但我不知道在哪里应用过滤器.

是否有一种快速的方法来应用过滤器将其更改为显示为之前的显示?

php wordpress product variations woocommerce

4
推荐指数
1
解决办法
3561
查看次数

获取WooCommerce中变量产品价格的所有变体属性

需要以"常规价格"方式显示属性变体.然而,尽管尝试了显示价格没有成功.请参阅下面显示变化精细的代码.请帮忙显示价格.

       //Getting product attributes
    $product_attributes = $product->get_attributes();

    if(!empty($product_attributes)){
        //Getting product attributes slugs
        $product_attribute_slugs = array_keys($product_attributes);
        $count_slug = 0;
        echo '<div class="product_attributes">';
        foreach ($product_attribute_slugs as $product_attribute_slug){
            $count_slug++;

            // Removing "pa_" from attribute slug and adding a cap to first letter
            $attribute_name =  ucfirst( str_replace('pa_', '', $product_attribute_slug) );
            //echo $attribute_name . ' (';

            $attribute_values = get_terms($product_attribute_slug);
            $count_value = 0;
            //print_r(array_values($available_variations));
            foreach($attribute_values as $attribute_value){
                $count_value++;
                $attribute_name_value = $attribute_value->name; // name value
                $attribute_slug_value = $attribute_value->slug; // slug value
                $attribute_slug_value = $attribute_value->term_id; // ID value …
Run Code Online (Sandbox Code Playgroud)

php wordpress product variations woocommerce

4
推荐指数
1
解决办法
7686
查看次数

从 Woocommerce 变量产品中获取当前选择的变体和数据

情况:我在 Wordpress WooCommerce 商店中有一堆可变产品。在前端有一个带有多个选择输入的表单,让用户在将产品添加到购物车之前对其进行配置。价格和其他信息会随着可能的变化而变化,所以我需要跟踪它。

目的:用户更改表单后,Woocommerce 将input.variation_id使用新选择的变体的 ID更新隐藏字段。每当这种情况发生变化时,我都想知道这一点。

显然,有一些东西可以跟踪变化,效果很好:

$( ".variations_form" ).on( "woocommerce_variation_select_change", function () {
    console.log('form has changed'); // fires correctly
} );
Run Code Online (Sandbox Code Playgroud)

我还可以在更改之前读取该隐藏字段的值:

var id = $('input.variation_id').val();
console.log( id ); // returns correct value
Run Code Online (Sandbox Code Playgroud)

问题:但是当我尝试调用该函数中的值时,我将无法工作。

$( ".variations_form" ).on( "woocommerce_variation_select_change", function () {
    var id = $('input.variation_id').val();
    console.log( id ); // fires, but returns empty
} );
Run Code Online (Sandbox Code Playgroud)

我已经尝试了所有想到的方法。如果我直接在浏览器控制台中输入它,它可以工作,但是当我尝试使用上面的函数获取它时,它是空的。我能做什么?

我以前使用过,$('form.variations_form select').change(...);但它会弄乱变化,我想确保 Woocommerce 在我执行操作之前更新了所有信息。

forms jquery variations woocommerce

4
推荐指数
1
解决办法
7470
查看次数

PHP - preg_match - 如何将字符串大小写与之前或之后的任何内容匹配?

我有一个函数的一部分,如下所示:

if (preg_match("#\bscript\b#",$userInput))
{
    $bannedWord = 'script';
    logHax();
    return TRUE;
}
Run Code Online (Sandbox Code Playgroud)

这导致了我想要完成的问题,因为它只匹配确切的单词"script"而不是它的变体,如"ScriPt"或" <script>".

我想要的是不匹配字符串的示例以及原始字符串返回true.

有人能就此事向我提供一些了解.

此外,任何涵盖此类内容的教程都将非常感激,

谢谢!

php preg-match variations

3
推荐指数
1
解决办法
2万
查看次数

Woocommerce显示默认变化价格

我正在使用Woocommerce和产品变体,所有变体都定义了默认变体。我想知道如何找到默认变体并显示其价格。

这是我到目前为止获得的代码,但是它显示了最低的变动价格,而我正在寻找默认的变动产品价格。

// Use WC 2.0 variable price format, now include sale price strikeout
add_filter( 'woocommerce_variable_sale_price_html', 'wc_wc20_variation_price_format', 10, 2 );
add_filter( 'woocommerce_variable_price_html', 'wc_wc20_variation_price_format', 10, 2 );
function wc_wc20_variation_price_format( $price, $product ) {
// Main Price
$prices = array( $product->get_variation_price( 'min', true ), $product->get_variation_price( 'max', true ) );
$price = $prices[0] !== $prices[1] ? sprintf( __( 'HERE YOUR LANGUAGE: %1$s', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );
// Sale Price
$prices = array( $product->get_variation_regular_price( 'min', true ), $product->get_variation_regular_price( …
Run Code Online (Sandbox Code Playgroud)

wordpress variations woocommerce

3
推荐指数
2
解决办法
7608
查看次数

获取WooCommerce变量产品中每个有效变体的库存数量

我需要显示Woocommerce中可变产品的每个变体的库存定量

我使用此代码显示库存数量:

<?php echo $product->get_stock_quantity(get_the_ID()); ?>
Run Code Online (Sandbox Code Playgroud)

现在我有这个产品:

衬衫有红色,蓝色代表可变产品。

“红色衬衫”的库存数量为3
“蓝色衬衫”的库存数量为4

所以我需要证明:

蓝色= 3 //红色= 4

我该怎么做?

php wordpress product variations woocommerce

3
推荐指数
1
解决办法
4636
查看次数

我如何为变量分配不同的变化,所以如果输入匹配分配的变量之一,则答案是正确的

创建一个猜词游戏和secret_word可以有任何变化,但是我将如何编写程序识别出的secret_word的不同变化?

在这种情况下,秘密词是“韩国”,我如何才能统一任何变体,或者我必须插入每种不同的变体?

secret_word = {"korea", "kOrea", "KoRea", "KoReA", "KOrea, "KORea", 
"Korea", "KOREA"}
guess = ""
guess_count = 0
guess_limit = 3
out_of_guesses = False

while guess != secret_word and not (out_of_guesses):
    if guess_count < guess_limit:
        guess = input("Guess a word: ")
        guess_count += 1
    else:
        out_of_guesses = True

if out_of_guesses:
print("Maybe Next time! You are out of guesses")
else:
    print("You win!")
Run Code Online (Sandbox Code Playgroud)

python string variations

3
推荐指数
1
解决办法
48
查看次数

产品变体WP_Query与Woocommerce中的产品类别

通过Woocommerce,我正在尝试使用产品类别"Apple"为产品变体发布类型的WP_Query.

$args = array(
    'product_cat'    => 'Apple',
    'post_type'      => array('product', 'product_variation'),
    'post_status'    => 'publish',
    'key'            => '_visibility',
    'value'          => 'visible',
    'posts_per_page' => 100,
    'taxonomy'       => 'pa_size',
    'meta_value'     => '39',
    'meta_query'     => array(
        array(
            'key'         => '_stock',
            'value'       => 0,
            'compare'     => '>'
        )
    )
);
Run Code Online (Sandbox Code Playgroud)

但我无法在此查询中使用它.如果我删除'product_cat' => 'Apple',查询工作.为什么?

php product variations custom-taxonomy woocommerce

2
推荐指数
1
解决办法
2183
查看次数