我正在尝试按照本教程(https://www.digitalocean.com/community/tutorials/how-to-install-configure-pgadmin4-server-mode)在 Ubuntu 18.04 上使用 python3 安装 pgAdmin4,但是在配置 pgAdmin4 时我得到了这个错误:
(my_env) 1 jess@hilarioserver:~/environments$ python my_env/lib/python3.6/site-packages/pgadmin4/setup.py
Traceback (most recent call last):
File "my_env/lib/python3.6/site-packages/pgadmin4/setup.py", line 17, in <module>
from pgadmin.model import db, User, Version, ServerGroup, Server, \
File "/home/cta/environments/my_env/lib/python3.6/site-packages/pgadmin4/pgadmin/__init__.py", line 21, in <module>
from flask_babelex import Babel, gettext
File "/home/cta/environments/my_env/lib/python3.6/site-packages/flask_babelex/__init__.py", line 23, in <module>
from werkzeug import ImmutableDict
ImportError: cannot import name 'ImmutableDict'
Run Code Online (Sandbox Code Playgroud)
我已经尝试安装werkzeug,但仍然出现相同的错误。
alembic (1.4.0) Babel (2.8.0) bcrypt (3.1.7) flasher (1.4) cffi (1.13.2) Click (7.0) 密码学 (2.8) Flask …
我正在创建一种为我的主题定制的可变产品,我设法出现在产品数据的下拉列表中,并且可以在不引起冲突的情况下进行保存。问题是在前端看到产品给了我以下错误:
警告: 在第 83 行的/Applications/MAMP/htdocs/canopy/wp-content/plugins/Woocommerce/includes/class-wc-product-variable.php 中为 foreach() 提供的参数无效
我已将问题追溯到文件,Wordpress/includes/data-stores/class-wc-product-variable-data-store-cpt.php但事实是我不知道还能做什么。
我留下我为此编写的代码:
WC_Product_variable_canopytour.php
class WC_Product_Variable_CanopyTour extends WC_Product_Variable {
public function __construct( $product ) {
$this->product_type = 'variable_canopytour';
parent::__construct( $product );
}
public function get_type() {
return 'variable_canopytour';
}
}
Run Code Online (Sandbox Code Playgroud)
class-woocommerce-custom-product.php
class WCB_Woocommerce_CanopyTour_Product_Type {
private $wcb;
private $version;
public function __construct( $wcb, $version ) {
$this->wcb = $wcb;
$this->version = $version;
}
public function register_canopytour_product_type() {
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
include_once(get_template_directory() . 'woocommerce/WC_Product_variable_canopytour.php');
}
public function add_canopytour_product( $types …Run Code Online (Sandbox Code Playgroud) 我正在尝试在 Woocommerce 的产品属性中创建自定义字段。这样就能够选择是否突出显示某个属性。例如:
https://i.stack.imgur.com/Ge76B.png
我想要做的是,我在后端指定为突出显示的字段以某种方式在前端显示。
到目前为止,我已经能够添加该字段,但我还没有弄清楚如何保存它。这就是我所拥有的:
add_action('woocommerce_after_product_attribute_settings','wcb_add_product_attribute_is_highlighted', 10, 2);
add_filter( 'woocommerce_admin_meta_boxes_prepare_attribute', 'wcb_admin_meta_boxes_prepare_attribute', 10, 3);
function get_attribute_highlighted($id, $i) {
return get_post_meta( 1, "attribute_".$id."_highlighted_".$i, true);
}
function wcb_add_product_attribute_is_highlighted($attribute, $i=0) {
$value = get_attribute_highlighted($attribute->get_id(), $i); ?>
<tr>
<td>
<div class="enable_variation show_if_canopytour show_if_variable_canopytour">
<label><input type="checkbox" class="checkbox" <?php checked( $value, true ); ?> name="attribute_highlighted[<?php echo esc_attr( $i ); ?>]" value="1" /> <?php esc_html_e( 'Highlight attribute', $this->wcb ); ?></label>
</div>
</td>
</tr>
<?php
}
function wcb_admin_meta_boxes_prepare_attribute($attribute, $data, $i=0) {
// updated
if(array_key_exists("attribute_highlighted", $data) && is_array($data["attribute_highlighted"])) …Run Code Online (Sandbox Code Playgroud)