Ниже приведен мой код в WordPress на pmpro-woocommerce.php. С этим кодом я сталкиваюсь с ошибкой:
Предупреждение. В foreach () указан неверный аргумент в \ pmpro-woocommerce.php в строке 517
Предупреждение: неверный аргумент указан для foreach () в \ pmpro-woocommerce.php в строке 561
add_action( 'woocommerce_product_write_panel_tabs', 'pmprowoo_tab_options_tab' );
/ **
* Добавить поля на вкладку PMPro
* /
function pmprowoo_tab_options () {
global $membership_levels, $post;
$membership_level_options = array( 'None' );
foreach ( $membership_levels as $option ) {
$key = $option->id;
$membership_level_options[ $key ] = $option->name;
}
?>
<div id="pmprowoo_tab_data" class="panel woocommerce_options_panel">
<div class="options_group">
<p class="form-field">
<strong><?php _e( 'Give Customers a Membership Level', 'pmpro-woocommerce' ); ?></strong><br/>
<?php
// Membership Product
woocommerce_wp_select(
array(
'id' => '_membership_product_level',
'label' => __( 'Membership Product', 'pmpro-woocommerce' ),
'options' => $membership_level_options,
)
);
// Membership Product
if( !empty( $post->ID ) ) {
$cbvalue = get_post_meta( $post->ID, '_membership_product_autocomplete', true );
}
if( empty( $cbvalue ) ) {
$cbvalue = NULL;
}
woocommerce_wp_checkbox(
array(
'id' => '_membership_product_autocomplete',
'label' => __( 'Autocomplete Order Status', 'pmpro-woocommerce' ),
'description' => __( "Check this to mark the order as completed immediately after checkout to activate the associated membership.", 'pmpro-woocommerce' ),
'cbvalue' => $cbvalue,
)
);
?>
</p>
</div>
<div class="options-group">
<p class="form-field">
<strong><?php _e( 'Member Discount Pricing', 'pmpro-woocommerce' ); ?></strong><br/>
<?php
// For each membership level, create respective price field
foreach ( $membership_levels as $level ) {
woocommerce_wp_text_input(
array(
'id' => '_level_' . $level->id . '_price',
'label' => __( $level->name . " Price", 'pmpro-woocommerce' ),
'placeholder' => '',
'type' => 'text',
'desc_tip' => 'true',
'data_type' => 'price',
)
);
}
?>
</p>