wp_remote_get debug hooks

function omniwp_wcte_display_api_curl( &$handle, $args, $url ) {

if ( false === strpos( $url, ‘https://api.ticketevolution.com/v9/’ ) )
return;

curl_setopt( $handle, CURLOPT_HTTPHEADER, array(
‘X-Signature: L9pBrEKzOtA7hTx3DqMV++pZRBvwQdQQ0Fwpk84t+wg=’,
‘X-Token: 53b043316ee369508295ee0cb9cca1ae’,
)
);
echo ‘<pre>omniwp_wcte_display_api_curl url
‘ .  print_r( $url, true ) . ‘</pre>’;
echo ‘<pre>omniwp_wcte_display_api_curl
‘ .  print_r( $args, true ) . ‘</pre>’;
}

add_action( ‘http_api_curl’, ‘omniwp_wcte_display_api_curl’, 10, 3 );

function omniwp_wcte_display_http_request_args( $args, $url ) {
echo ‘<pre>omniwp_wcte_display_http_request_args args
‘ .  print_r( $args, true ) . ‘</pre>’;
return $args;
}
//add_filter( ‘http_request_args’, ‘omniwp_wcte_display_http_request_args’, 10, 2 );

function omniwp_wcte_display_http_api_transport_args( $transport, $args, $url ) {
echo ‘<pre>omniwp_wcte_display_http_api_transport_args transport ' . print_r( $transport, 1 ) . '
‘ .  print_r( $args, true ) . ‘</pre>’;
return $transport;
}

//add_filter( ‘http_api_transports’, ‘omniwp_wcte_display_http_api_transport_args’, 10, 3 );

function omniwp_wcte_display_api_debug( $response, $context, $class, $args, $url ){
echo ‘<pre>omniwp_wcte_display_api_debug context
‘ .  print_r( $context, true ) . ‘</pre>’;
echo ‘<pre>omniwp_wcte_display_api_debug http args
‘ .  print_r( $args, true ) . ‘</pre>’;
}

//add_action( ‘http_api_debug’, ‘omniwp_wcte_display_api_debug’, 10, 5 );

Variações de produtos: link para mostar variação selecionda / adicionar variação selecionada ao carrinho

Show variation links:

http://jococups.com/shop/12oz-joco-cup/?colour=mint


add_filter( 'woocommerce_product_default_attributes', 'maybe_change_colour');

function maybe_change_colour( $default_attributes ) {
if ( isset( $_GET['colour'] ) ) {
$default_attributes['colour'] = $_GET['colour'];
}
return $default_attributes;
}


Add to cart links:

 

Links are like

http://jococups.com/?add-to-cart=145&variation_id=202&quantity=1attribute_pa_colour=red

One needs to change variation_id and attribute_pa_colour