Skip to content

Instantly share code, notes, and snippets.

/criaPedido.php Secret

Created June 7, 2016 23:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/68719204ed6f2d92ee40f23f73c59e3b to your computer and use it in GitHub Desktop.
Save anonymous/68719204ed6f2d92ee40f23f73c59e3b to your computer and use it in GitHub Desktop.
<?
$qtd = $_POST['QTD'];
$total = $_POST['TOTAL'];
$_SESSION['qtd'] = $qtd;
$_SESSION['total'] = $total;
?>
<!--A princípio eu terei 2 campos para gerar o preço, um para quanitdade, outro para o valor -->
<!--Ex: o usuario incere na 'qtd' o valor '1', no campo 'total' ira aparecer '2999.00' isto está pronto -->
<?php
//include_once ('functions.php');
$custom_price = /* recebe o $total*/;
$address = array( /*Todos estes dados vêm de inputs anteriores*/
'first_name' => $nome,
'last_name' => $sobrenome,
'email' => $email,
'phone' => $fone,
'address_1' => $endereco,
'postcode' => $cep,
);
/* Aqui a parte que precisa criar o pedido, só que com o valor custom '$total', sem produto e quantidade é chamada de '$qtd'*/
$order = wc_create_order();
$order = new WC_Order( $order_id );
$order->set_total( $qtd);
$order->set_address( $address, 'billing' );
$order->set_address( $address, 'shipping' );
$order->update_status( 'processing' );
/*// Process Payment
$available_gateways = WC()-&gt;payment_gateways-&gt;get_available_payment_gateways();
$result = $available_gateways[ 'ideal' ]-&gt;process_payment( $order-&gt;id );
Redirect to success/confirmation/payment page
if ( $result['result'] == 'success' ) {
$result = apply_filters( 'woocommerce_payment_successful_result', $result, $order-&gt;id );
wp_redirect( $result['redirect'] );
exit;
}*/
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment