Ir para conteúdo
View in the app

A better way to browse. Learn more.

GGames Fórum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
Postado
  • Fundador

Colocando preço do produto variável dentro do DROPDOWN


Um código simples para ajuda-lo a expor o preço do seus produtos variáveis dentro na hora do cliente selecionar. Por padrão não é exibido! Para exibir basta editar o arquivo FUNCTIONS.PHP do seu tema e colar o seguinte código no final; //Add prices to variations add_filter( 'woocommerce_variation_option_name', 'display_price_in_variation_option_name' ); function display_price_in_variation_option_name( $term ) { global $wpdb, $product; $result = $wpdb->get_col( "SELECT slug FROM {$wpdb->prefix}terms WHERE name = '$term'" ); $term_slug = ( !empty( $result ) ) ? $result[0] : $term; $query = "SELECT postmeta.post_id AS product_id FROM {$wpdb->prefix}postmeta AS postmeta LEFT JOIN {$wpdb->prefix}posts AS products ON ( products.ID = postmeta.post_id ) WHERE postmeta.meta_key LIKE 'attribute_%' AND postmeta.meta_value = '$term_slug' AND products.post_parent = $product->id"; $variation_id = $wpdb->get_col( $query ); $parent = wp_get_post_parent_id( $variation_id[0] ); if ( $parent > 0 ) { $_product = new WC_Product_Variation( $variation_id[0] ); $itemPrice = strip_tags (woocommerce_price( $_product->get_price() )); //this is where you can actually customize how the price is displayed return $term . ' (' . $itemPrice . ')'; } return $term; } O código é de autoria do Derek, achei no google nesse blog. Mesmo sendo de 2013, funcionou direitinho!

  • Autor
    Este é um conteúdo oculto, por favor
  • Categoria
    Este é um conteúdo oculto, por favor
  • Enviado
    26-10-2018 12:49

 

Antes de perguntar, visite a Wiki GGames | Ajude-se a manter o fórum se tornando VIP e ganhe convites! 

Junta-se ao Telegram Oficial do GGames, lá pode falar de tudo! | Clique aqui

 

  • Visualizações 1,4k
  • Criado
  • Última resposta

Posts Recomendados

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.