add_action ( 'wp_print_scripts', 'my_deregister_javascript', 100 );
function jquery_script_method () {
global $post;
if ( $post->post_type == 'product' || $post->ID == '15' ) {
wp_dequeue_script ( 'contact-form-7' );
wp_dequeue_script ( 'js_composer' );
}
}
function wc_get_formatted_cart_item_data( $cart_item, $flat = false ) {
$item_data = array();
// Variation values are shown only if they are not found in the title as of 3.0.
// This is because variation titles display the attributes.
if ( $cart_item['data']->is_type( 'variation' ) && is_array( $cart_item['variation'] ) ) {
foreach ( $cart_item['variation'] as $name => $value ) {
$taxonomy = wc_attribute_taxonomy_name( str_replace( 'attribute_pa_', '', urldecode( $name ) ) );
if ( taxonomy_exists( $taxonomy ) ) {
// If this is a term slug, get the term's nice name.
$term = get_term_by( 'slug', $value, $taxonomy );
if ( ! is_wp_error( $term ) && $term && $term->name ) {
$value = $term->name;
}
$label = wc_attribute_label( $taxonomy );
} else {
// If this is a custom option slug, get the options name.
$value = apply_filters( 'woocommerce_variation_option_name', $value );
$label = wc_attribute_label( str_replace( 'attribute_', '', $name ), $cart_item['data'] );
}
// Check the nicename against the title.
if ( '' === $value || wc_is_attribute_in_product_name( $value, $cart_item['data']->get_name() ) ) {
continue;
}
$item_data[] = array(
'key' => $label,
'value' => $value,
);
}
}
// Filter item data to allow 3rd parties to add more to the array.
$item_data = apply_filters( 'woocommerce_get_item_data', $item_data, $cart_item );
// Format item data ready to display.
foreach ( $item_data as $key => $data ) {
// Set hidden to true to not display meta on cart.
if ( ! empty( $data['hidden'] ) ) {
unset( $item_data[ $key ] );
continue;
}
$item_data[ $key ]['key'] = ! empty( $data['key'] ) ? $data['key'] : $data['name'];
$item_data[ $key ]['display'] = ! empty( $data['display'] ) ? $data['display'] : $data['value'];
}
// Output flat or in list format.
if ( count( $item_data ) > 0 ) {
ob_start();
if ( $flat ) {
foreach ( $item_data as $data ) {
echo esc_html( $data['key'] ) . ': ' . wp_kses_post( $data['display'] ) . "\n";
}
} else {
wc_get_template( 'cart/cart-item-data.php', array( 'item_data' => $item_data ) );
}
return ob_get_clean();
}
return '';
}
array(3) {
["key"]=>
string(8) "Цвет"
["value"]=>
string(7) "chernyj"
["display"]=>
string(7) "chernyj"
}
array(3) {
["key"]=>
string(8) "Цвет"
["value"]=>
string(7) "chernyj"
["display"]=>
string(7) "chernyj"
}
<ul class="variation">
<?php foreach ( $item_data as $data ) : ?>
<li class="variation-<?php echo sanitize_html_class( $data['key'] ); ?>">
<span class="item-variation-name"><?php echo wp_kses_post( $data['key'] ); ?>:</span>
<span class="item-variation-value"><?php echo wp_kses_post( wpautop( $data['display'] ) ); ?></span>
</li>
<?php endforeach; ?>
</ul>
add_filter('woocommerce_variable_price_html', 'mycustom_variation_price', 10, 2);
add_filter('woocommerce_variable_sale_price_html', 'mycustom_variation_price', 10, 2 );
function mycustom_variation_price( $price, $product ) {
if ( ! is_admin() && ((is_shop() || is_product_category() || is_page() || is_single() || is_product()))) {
$price = '';
$price .= woocommerce_price($product->get_price());
}
return $price;
}