$user_rate = intval( get_comment_meta( $comment->comment_ID, 'rating', true ) )
<?php
/**
* @package TAXO CRM
* @author WP_Panda
* @version 0.2.1
*/
require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php' );
$metas = [
'key_1' => 1,
'key_2' => 1,
'key_3' => 1,
'key_3' => 1
];
$post_data = [
'post_content' => 'Контент контент контент',
'post_status' => 'publish',
'post_author' => 1,
'post_category' => [ 8, 39 ]
];
$start = microtime(true);
$i = 1;
while ( $i <= 1000 ) {
$post_data[ 'post_title' ] = 'Запись ' . $i;
$post_id = wp_insert_post( $post_data );
foreach ( $metas as $meta_key => $meta_val ) {
update_post_meta( $post_id, $meta_key, $meta_val );
}
$i ++;
}
$time = microtime(true) - $start;
printf( 'Время выполнения: %s мс', $time );
function wpp_is_available_free( $is_available ) {
$free_products = [ 22, 55, 44, 66, 22 ];
foreach ( WC()->cart->get_cart() as $key => $item ) {
if ( in_array( $item[ 'product_id' ], $free_products ) ) {
return true;
}
}
return $is_available;
}
add_filter( 'woocommerce_shipping_free_shipping_is_available', 'wpp_is_available_free', 30 );
Я не программист, и стандартными настройками Woocommerce не могу настроить эти функции.
function wpp_get_product_attributes( $product = null, $count = null ) {
if ( empty( $product ) ) :
global $product;
endif;
$attributes = array_filter( $product->get_attributes(), 'wc_attributes_array_filter_visible' );
$i = 1;
foreach ( $attributes as $attribute ) {
if ( ! empty( (int) $count ) && (int) $count > $i ) {
break;
}
$values = [];
if ( $attribute->is_taxonomy() ) {
$attribute_taxonomy = $attribute->get_taxonomy_object();
$attribute_values = wc_get_product_terms( $product->get_id(), $attribute->get_name(), [ 'fields' => 'all' ] );
foreach ( $attribute_values as $attribute_value ) {
$value_name = esc_html( $attribute_value->name );
if ( $attribute_taxonomy->attribute_public ) {
$values[] = '<a href="' . esc_url( get_term_link( $attribute_value->term_id, $attribute->get_name() ) ) . '" rel="tag">' . $value_name . '</a>';
} else {
$values[] = $value_name;
}
}
} else {
$values = $attribute->get_options();
foreach ( $values as &$value ) {
$value = make_clickable( esc_html( $value ) );
}
}
$product_attributes[ 'attribute_' . sanitize_title_with_dashes( $attribute->get_name() ) ] = [
'label' => wc_attribute_label( $attribute->get_name() ),
'value' => apply_filters( 'woocommerce_attribute', wpautop( wptexturize( implode( ', ', $values ) ) ), $attribute, $values ),
];
$i ++;
}
$product_attributes = apply_filters( 'woocommerce_display_product_attributes', $product_attributes, $product );
?>
<table class="woocommerce-product-attributes shop_attributes">
<?php foreach ( $product_attributes as $product_attribute_key => $product_attribute ) : ?>
<tr class="woocommerce-product-attributes-item woocommerce-product-attributes-item--<?php echo esc_attr( $product_attribute_key ); ?>">
<th class="woocommerce-product-attributes-item__label"><?php echo wp_kses_post( $product_attribute['label'] ); ?></th>
<td class="woocommerce-product-attributes-item__value"><?php echo wp_kses_post( $product_attribute['value'] ); ?></td>
</tr>
<?php endforeach; ?>
</table>
<?php
}
add_filter( 'woocommerce_cart_calculate_fees', 'add_my_fee', 10, 1 );
function add_my_fee() {
$gateway = WC()->session->get( 'chosen_payment_method' );
if ( $gateway == 'paypal' ) {
WC()->cart->add_fee( 'Наценка за метод оплаты который нам не нравится', 100 );
}
}