Skip to content

Instantly share code, notes, and snippets.

@luiseduardobraschi
Last active May 28, 2023 00:57
Show Gist options
  • Save luiseduardobraschi/9677ca58fbc868fff98356897fab7fac to your computer and use it in GitHub Desktop.
Save luiseduardobraschi/9677ca58fbc868fff98356897fab7fac to your computer and use it in GitHub Desktop.
[Fórum WP] PIX Pagar.me não copia código.

Esse código deve ser adicionado ao functions.php (o trecho "<?php" deve ser removido) do tema atual ou usando um plugin que permita adição de "snippets" (ou trechos de código PHP).

Um exemplo de plugin é o Code Snippets: https://br.wordpress.org/plugins/code-snippets/

<?php
add_action( 'wp_enqueue_scripts', function(){
$is_pix_payment_page = function(){
global $wp;
//Page is view order or order received?
if( !isset($wp->query_vars['order-received']) && !isset($wp->query_vars['view-order']) )
return;
$query_var = isset($wp->query_vars['order-received']) ? $wp->query_vars['order-received'] : $wp->query_vars['view-order'];
$order_id = absint( $query_var );
if ( empty($order_id) || $order_id == 0 )
return;
$order = wc_get_order( $order_id );
if( !$order )
return;
if( ( ( is_wc_endpoint_url('order-received') && is_checkout() ) ||
is_wc_endpoint_url( 'view-order' ) ) &&
'wc_pagarme_pix_payment_geteway' == $order->get_payment_method()
)
return true;
return false;
};
if( $is_pix_payment_page() ){
wp_enqueue_script( 'bug-pix-pagarme', \WC_PAGARME_PIX_PAYMENT_PLUGIN_URL . 'assets/js/public/checkout.js', array( 'jquery' ), \WC_PAGARME_PIX_PAYMENT_PLUGIN_VERSION );
}
}, 20 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment