RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-263560

Pavel8289's questions

Martin Hope
Pavel8289
Asked: 2021-10-20 03:44:49 +0000 UTC

woocommerce。在管理面板中以编程方式保存可变产品的折扣价格

  • 1

我使用此代码向变体添加了一个自定义字段,并且可以通过百分比折扣计算产品的价格。问题是,哪个钩子负责在保存设置之前更改折扣价格?

 // -----------------------------------------
// 1. Add custom field input @ Product Data > Variations > Single Variation

add_action( 'woocommerce_variation_options_pricing', 'bbloomer_add_custom_field_to_variations', 10, 3 );

function bbloomer_add_custom_field_to_variations( $loop, $variation_data, $variation ) {
woocommerce_wp_text_input( array(
'id' => 'custom_field[' . $loop . ']',
'class' => 'short',
'label' => __('The Percent of Sales', 'woocommerce' ),
'value' => get_post_meta( $variation->ID, 'custom_field', true )
)
);
}

// -----------------------------------------
// 2. Save custom field on product variation save

add_action( 'woocommerce_save_product_variation', 'bbloomer_save_custom_field_variations', 10, 2 );

function bbloomer_save_custom_field_variations( $variation_id, $i ) {
$custom_field = $_POST['custom_field'][$i];
if ( isset( $custom_field ) ) update_post_meta( $variation_id, 'custom_field', esc_attr( $custom_field ) );

}

// -----------------------------------------
// 3. Store custom field value into variation data

add_filter( 'woocommerce_available_variation', 'bbloomer_add_custom_field_variation_data' );

function bbloomer_add_custom_field_variation_data( $variations ) {
$variations['custom_field'] = '<div class="woocommerce_custom_field">The Percent of Sales: <span>' . get_post_meta( $variations[ 'variation_id' ], 'custom_field', true ) . '</span></div>';
return $variations;
}

UPD:据我了解,只有这样存钱才能打折?

update_post_meta( $variation_id, 'variable_sale_price', '10' );
wordpress
  • 1 个回答
  • 10 Views
Martin Hope
Pavel8289
Asked: 2020-05-02 04:15:07 +0000 UTC

Route::group 的问题

  • 0

问候。我有一个包含基本路由的帖子部分,我决定添加另一个附件帖子/已删除但我无法访问它。

因为它是

Route::group(['namespace' => 'Admin', 'prefix' => 'admin', 'middleware' => 'auth'],
    function () {       
        Route::resource('posts', 'BlogPostController', ['names' => 'admin.posts']);
    });

我正在尝试在帖子中添加垃圾作为另一个深度,其中来自 BlogPostController 的方法只需要一个被垃圾的函数

Route::group(['namespace' => 'Admin', 'prefix' => 'admin', 'middleware' => 'auth'],
    function () {       
        Route::resource('posts', 'BlogPostController', ['names' => 'admin.posts']);

        Route::get('posts/trashed', ['uses' => 'BlogPostController@trashed',
            'as' => 'admin.posts.trashed']);
    });

按上述方法列出的路线列表

|        | POST      | admin/posts                      | admin.posts.store        | App\Http\Controllers\Admin\BlogPostController@store                    | web,auth  
                                           |
|        | GET|HEAD  | admin/posts                      | admin.posts.index        | App\Http\Controllers\Admin\BlogPostController@index                    | web,auth  
                                           |
|        | GET|HEAD  | admin/posts/create               | admin.posts.create       | App\Http\Controllers\Admin\BlogPostController@create                   | web,auth  
                                           |
|        | GET|HEAD  | admin/posts/trashed              | admin.posts.trashed      | App\Http\Controllers\Admin\BlogPostController@trashed                  | web,auth  
                                           |
|        | DELETE    | admin/posts/{post}               | admin.posts.destroy      | App\Http\Controllers\Admin\BlogPostController@destroy                  | web,auth  
                                           |
|        | GET|HEAD  | admin/posts/{post}               | admin.posts.show         | App\Http\Controllers\Admin\BlogPostController@show                     | web,auth  
                                           |
|        | PUT|PATCH | admin/posts/{post}               | admin.posts.update       | App\Http\Controllers\Admin\BlogPostController@update                   | web,auth  
                                           |
|        | GET|HEAD  | admin/posts/{post}/edit          | admin.posts.edit         | App\Http\Controllers\Admin\BlogPostController@edit                     | web,auth

摘自 BlogPostController.php

 public function trashed()
    {

        $posts = $this->blogPostRepository->getAllWithPaginateTrash(5);

        return view('admin.posts.index', compact('posts'));

    }

问题是Route::group不起作用,它只是显示一个没有404错误的白页,没有任何其他错误,并且在这个页面上调试不起作用。我以这种方式将其从组中取出,然后一切正常,数据来自我对链接的期望

Route::get('posts/trashed', ['uses' => 'Admin\BlogPostController@trashed',
                'as' => 'admin.posts.trashed']);

但我希望它位于 Route::group 中,并且只有一条路线是用垃圾建造的。

怎么做?

laravel
  • 1 个回答
  • 10 Views
Martin Hope
Pavel8289
Asked: 2020-12-25 00:51:04 +0000 UTC

VueJS、i18n 和 vue-meta 如何与这一切交朋友

  • 1

我正在使用i18n语言更改插件以及vue-meta页面上的元标记插件。i18n 插件非常适合更改站点语言。但是要更改页面的元数据,不知道如何将它们全部连接起来。

App.vue 看起来像这样。如果只在其中写入文本,metaInfo 可以很好地加载信息。虽然它是静态工作的,但是当站点语言发生变化时,如何使字段中的信息动态变化?

export default {
        name: 'name',
        metaInfo: {
            title: 'название страницы', // set a title
            titleTemplate: '%s - продолжение название страницы', // %s  required
            htmlAttrs: {
                lang: 'ru',
                amp: undefined // "amp" has no value
            },
            meta: [
                {   'name':'og:title',
                    'content': 'название',
                },
                {   'name':'metatitle',
                    'content': 'название',
                },
                {   'name':'og:description',
                    'content': 'описание',
                },
                {   'name':'description',
                    'content': 'описание',
                }

            ]

        },
        data(){return{}}
vue.js
  • 2 个回答
  • 10 Views
Martin Hope
Pavel8289
Asked: 2020-11-16 00:48:51 +0000 UTC

Vue.js 和 Uikit 3

  • 0

在 vue + uikit 3 上搭建了一个有几个页面的站点。在移动版本中,我使用标准的 uikit off-canvas 作为菜单。问题是打开移动菜单(off-canvas)后,off-canvas并没有隐藏,而是通过点击菜单项进行到页面的过渡。

UIkit 文档说你可以用这个脚本“UIkit.offcanvas(element).hide();”关闭它 如何与 vue.js 交朋友?

编写一个插入这段代码的方法不起作用(

https://getuikit.com/docs/offcanvas#off-canvas

UPD:找到了解决方案。留在答案中

vue.js
  • 1 个回答
  • 10 Views
Martin Hope
Pavel8289
Asked: 2020-09-08 01:04:04 +0000 UTC

N次后换图

  • 0

这个想法是写一个滑块,这样在 N 次之后,带有文本的图片就会变成另一张幻灯片,等等。在一个圆圈中,也可以使用 dotnav 在前后滚动幻灯片。在 JQ 上,我会很快做所有事情,但使用 Vue 并仅使用它不会很快奏效。

N次后,在“li”标签中写入活动类,删除前一个,它应该与dotnav对称。谁能为此提供建议或帮助?感谢大家的回应!

var app = new Vue({
        el: '#app',
        data: {
            message: 'Hello Vue!',
            items: [
                {
                    title: 'Center of osteopatia and rehabilitation',
                    url_img: 'https://i.imgur.com/gQp3VSW.jpg',
                    info_block: [
                        {
                            incremental: '+800%',
                            description: 'Increasing the number of transactions from organic search results'
                        },
                        {
                            incremental: '+240%',
                            description: 'Raising your revenue'
                        }

                    ]
                },
                {
                    title: 'SLide 2',
                    url_img: 'https://newevolutiondesigns.com/images/freebies/space-wallpaper-5.jpg',
                    info_block: [
                        {
                            incremental: '+140%',
                            description: 'Increasing the numb organic search results'
                        },
                        {
                            incremental: '+790%',
                            description: 'Raising your revenue'
                        }

                    ]
                },
                {
                    title: ' SLIDE 3',
                    url_img: 'https://www.planwallpaper.com/static/images/4433836-space-wallpapers.jpg',
                    info_block: [
                        {
                            incremental: '+110%',
                            description: 'Increasing the number of trans'
                        },
                        {
                            incremental: '+99%',
                            description: 'Raising your revenue'
                        }

                    ]
                }
            ]
        },

        methods: {
            index_dotnav:function (index) {
                console.log(index);

            }


        }


    })
    ul{
        padding-left: 0;
        margin: 0;
    }
    .img-block,
    section > *,
    .uk-slideshow,
    .uk-slideshow > ul {
        height: 100vh !important;
    }

    .information-slide .uk-container {
        position: absolute;
        z-index: 1;
        top: 0;
        bottom: 0;
        right: 0;
        left: 0;
        margin: auto 0;
        display: flex;
        flex-direction: column;
        justify-content: center;
        color: #fff;
    }

    .slideshow > div.dotnav-block {
        top: 50%;
        left: 95%;

        z-index: 2;
    }

    .slideshow > div.dotnav-block li a {
        background: #fff;
    }

    .slideshow > div.dotnav-block li.active a {
        width: 13px;
        height: 13px;
    }

    .slideshow > div.dotnav-block ul {
        align-items: center;
    }

    .slideshow .slideshow-items > li {
        display: none;
    }

    .slideshow .slideshow-items > li.active {
        display: block;
        position: relative;
    }

    .slideshow .slideshow-items > li img {
        height: 100%;
        width: auto;
        object-fit: cover;
    }
<!DOCTYPE html>
<html>
<head>
    <title>Тест</title>
    <meta charset="utf-8">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/uikit/3.0.0-rc.14/css/uikit.min.css"/>


</head>




<body>
<div id="app">
    <section>
        <div class="uk-child-width-1-2" uk-grid>
            <div>
                <h1>{{ message }}</h1>
            </div>
            <div>
                <div class="slideshow">

                    <ul class="slideshow-items">

                        <li v-for="(item,index) in items"  :class="{'active':index===0}" v-on:click="select($event)">

                            <div class="information-slide">
                                <div class="img-block">
                                    <img v-bind:src="item.url_img" alt="">
                                </div>
                                <div class="uk-container">
                                    <div class="title title-1">{{item.title}}</div>
                                    <div class="info-block">
                                        <div class="info" v-for="(iblock,ind) in item.info_block">
                                            <div class="incremental">{{iblock.incremental}}</div>
                                            <div class="description descr-1">{{iblock.description}}</div>
                                        </div>
                                    </div>

                                </div>
                            </div>
                        </li>
                    </ul>

                    <div class="dotnav-block uk-position-bottom-center uk-position-small">
                        <ul class="uk-dotnav uk-dotnav-vertical">
                            <li :class="{'active':index===0}"   v-for="(item,index) in items" v-on:click="index_dotnav(index)">
                                <a href="#">Item {{index}}</a></li>

                        </ul>
                    </div>

                </div>

            </div>

        </div>
    </section>
</div>

<script src="https://cdn.jsdelivr.net/npm/vue@2.5.17/dist/vue.js"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/uikit/3.0.0-rc.14/js/uikit.min.js"></script>


</body>

</html>

vue.js
  • 1 个回答
  • 10 Views
Martin Hope
Pavel8289
Asked: 2020-07-03 23:40:41 +0000 UTC

后台更新功能

  • 0

有一个工作代码可以从 facebook 中提取一篇文章,将其解析为组件并将其添加到站点数据库中。

有一个缺点 - 它现在挂在前端,并且在我访问站点/更新时开始工作 - 它有效。

我怎样才能让它在“后台”的后端工作?

在代码中,输入您需要转向从 FB 提取信息并每小时处理一次的函数的时间。

场景如下:我在 facebook 上发布了新闻,一个小时后,WordPress 代码本身会定期检查并将新闻添加到数据库中(如果有的话)。比方说,该网站是通过 facebook 填充的,而无需对该网站进行任何其他操作!

谁知道这件事?

更新

插件文件中的代码 ****-admin.php

    add_filter('cron_schedules', 'add_weekly_cron_schedule');
function add_weekly_cron_schedule($schedules)
{
    $schedules['five_min'] = array(
        'interval' => 300
    );
    return $schedules;
}


if (!wp_next_scheduled('my_task_hook')) {
    wp_schedule_event(time(), "five_min", 'my_task_hook');
}

// добавляем крон хук
add_action('my_task_hook', 'my_task_function');
function my_task_function()
{
    wp_mail('mypost@mail.com', 'Статья новая', 'Запланированное письмо от WordPress.'); // информирую сам себя что  крон сработал

    $post_data = array(
        'post_title' => 'название статьи',
        'post_content' => 'тело',
        'post_status' => 'publish',
        'post_author' => 1,
        'post_category' => array(0)
    );

    wp_insert_post($post_data);
}

在服务器上注册

/usr/bin/wget -qO- /home/toys4k00/домен/cbc/wp-cron.php?doing_wp_cron 

添加到 wp-config.php

define('DISABLE_WP_CRON', true);
define('ALTERNATE_WP_CRON', true);
wordpress
  • 1 个回答
  • 10 Views
Martin Hope
Pavel8289
Asked: 2020-11-15 22:06:45 +0000 UTC

轮播Bootstrap 4时整个网站上的字体闪烁

  • 1

有一个站点https://tcc.net.ua,它有 Bootstrap 4 并且由于轮播(幻灯片放映)字体闪烁,所以不清楚,在所有站点上都很明显。

闪烁示例https://gyazo.com/9072416d5b9604132447feaf91fc9165

如何解决这个问题?

css
  • 1 个回答
  • 10 Views
Martin Hope
Pavel8289
Asked: 2020-10-18 17:25:55 +0000 UTC

删除整页和每一行的特定字符

  • 2

有一个符号,比如说“$”符号,它可以在页面的不同部分和一行中的多个部分。

如何删除一个字符,使其到处消失?因此,它不是分机。空间,我试图通过包含来做到这一点,它删除了,比如说,行中的 1 个元素。

jquery
  • 1 个回答
  • 10 Views
Martin Hope
Pavel8289
Asked: 2020-10-13 13:28:13 +0000 UTC

Vue.js 测试的最佳问题存储

  • 1

在Vue.js中存储测试问题的最佳方式是什么。考试就是这样,从一个确定的答案中,会出现一个问题的痕迹,作为对前一个问题的答案。

为了生动的理解,心理学类型的测试会说,正如你所理解的,新的问题会从答案中出现。

我有两个想法,愚蠢地抛出一个列表..让我们说一下编号和比较调用ответ= новый вопрос。那是多大的学校。第二个想法是将所有内容放在Json树中,然后以某种方式沿着树走。

如果有其他选择,我会听的。

除了问题,测试的优化执行。如何if else围栏这一切可能并不好。构建测试代码有哪些想法?

javascript
  • 1 个回答
  • 10 Views
Martin Hope
Pavel8289
Asked: 2020-09-29 20:37:14 +0000 UTC

给列表编号

  • 0

有一个清单,你需要给它编号。编号意味着添加类:在级别 2ul中,例如,сlass_2在级别 3 ul-сlass_3中。它应该是这样的。

我认为解决方案在于 jQuery,但我不知道该怎么做。

<ul  class="class_1">
   <li>
      <ul class="class_2">
         <li></li>
         <li>
            <ul class="class_3">
               <li></li>
               <li></li>
               <li></li>
               <li></li>
            </ul>
         </li>
         <li></li>
         <li></li>
         <li></li>
      </ul>
   </li>
   <li>
      <ul class="class_2">
         <li></li>
         <li>
            <ul class="class_3">
               <li></li>
               <li></li>
               <li></li>
               <li></li>
            </ul>
         </li>
         <li>
            <ul class="class_3">
               <li></li>
               <li></li>
               <li></li>
               <li></li>
            </ul>
         </li>
         <li>
            <ul class="class_3">
               <li></li>
               <li></li>
            </ul>
         </li>
         <li></li>
      </ul>
   </li>
   <li></li>
</ul>
jquery
  • 2 个回答
  • 10 Views
Martin Hope
Pavel8289
Asked: 2020-09-10 23:09:54 +0000 UTC

按关键字输入单词的关联数组

  • 0

有 2 个数组,一个带有字母,第二个带有名称

 $name = array("Aндрей","Артур","Ваня","Виталик","Богдан");
 $alf =  array ("А","Б","В");

你需要得到这样的东西

Array
(
    [A] => Array
        (
            [0] => Aндрей
            [1] => Артур

        )

    [Б] => Array
        (
            [0] => Богдан

        )

 [В] => Array
        (
            [0] => Ваня
            [1] => Виталик
        )
)

它不能正确组织循环,以便它从字母表中获取第一个索引,并在名称数组上运行比较,如果第一个字母以字母表数组中的索引元素开头,则添加

php
  • 2 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5