Skip to content

Instantly share code, notes, and snippets.

@lpj145
Created May 30, 2020 18:24
Show Gist options
  • Save lpj145/9b4e6a75ef5b349079afbd5b35bd0f2b to your computer and use it in GitHub Desktop.
Save lpj145/9b4e6a75ef5b349079afbd5b35bd0f2b to your computer and use it in GitHub Desktop.
<?php
defined( 'ABSPATH' ) || exit;
$order = wc_get_order( $order_id ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited
if ( ! $order ) {
return;
}
$order_items = $order->get_items( apply_filters( 'woocommerce_purchase_order_item_types', 'line_item' ) );
$show_purchase_note = $order->has_status( apply_filters( 'woocommerce_purchase_note_order_statuses', array( 'completed', 'processing' ) ) );
$show_customer_details = is_user_logged_in() && $order->get_user_id() === get_current_user_id();
$downloads = $order->get_downloadable_items();
$show_downloads = $order->has_downloadable_item() && $order->is_download_permitted();
if ( $show_downloads ) {
wc_get_template(
'order/order-downloads.php',
array(
'downloads' => $downloads,
'show_title' => true,
)
);
}
?>
<?php
do_action( 'woocommerce_order_details_before_order_table_items', $order );
foreach ( $order_items as $item_id => $item ) {
$product = $item->get_product();
wc_get_template(
'order/order-details-item.php',
array(
'order' => $order,
'item_id' => $item_id,
'item' => $item,
'show_purchase_note' => $show_purchase_note,
'purchase_note' => $product ? $product->get_purchase_note() : '',
'product' => $product,
)
);
$Produtos .= "*".$item->get_quantity()."x* - ".$item->get_name()."%0a" .strip_tags(wc_display_item_meta($item, 'echo'))."%0a";
$soma += $item->get_total();
}
do_action( 'woocommerce_order_details_after_order_table_items', $order );
foreach ($order->meta_data as $valor) {
if($valor->key == "_billing_forma_de_pagamento"){
$fdepagamento = $valor->value;
}
if($valor->key == "_billing_precisa_de_troco"){
$ptroco = $valor->value;
}
if($valor->key == "_billing_troco_para_quanto"){
$troco = $valor->value;
}
if($valor->key == "_billing_notas_do_pedido"){
$notas = $valor->value;
}
}
$linkadoa = $order->get_id();
$linkadob = "https://criacaofoxdigital.com.br/ilove-burguers/print-order/$linkadoa";
$urlLink = sprintf('https://criacaofoxdigital.com.br/ilove-burguers/print-order/%d', $order->get_id());
$linkElemento = sprintf('<a href="%s" target="_blank">Imprimir: %d</a>', $urlLink, $order->get_id());
$dados .= "🗒 *PEDIDO Nº:* ".$order->get_id()."%0a";
$dados .= "----------------------------------------%0a";
$dados .= "😋 *PRODUTOS*%0a";
$dados .= $Produtos ;
$dados .= "----------------------------------------%0a";
$dados .= "💵 *TOTAL À PAGAR:* R$".number_format($order->get_total(),2,",",".")."%0a";
$dados .= "Cliente irá pagar na: ".$order->get_payment_method_title()."%0a";
$dados .= "Forma de pagamento: ".$fdepagamento."%0a";
$dados .= "Precisa de troco?: ".$ptroco."%0a";
$dados .= "Precisa de troco para: R$".$troco."%0a";
$dados .= "----------------------------------------%0a";
$dados .= "👤 *DADOS DO CLIENTE*%0a";
$dados .= "Nome: ".$order->get_billing_first_name()."%0a";
$dados .= "Endereço: ".$order->get_billing_address_1()."%0a";
$dados .= "Cidade: ".$order->get_billing_city()." %0a";
$dados .= "Ponto de Referência: ".$order->get_billing_address_2()."%0a";
$dados .= "Notas do Pedido: ".$notas."%0a";
$dados .= $linkElement;
$numeroZap = get_theme_mod('phone_whatsapp_configuration');
$telefone = $numeroZap;
header("Location: https://api.whatsapp.com/send?phone=".$telefone."&text=".$dados);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment