insertar producto por código
-
Hola.
Estoy tratando de insertar un producto por código a wocommercce que viene desde un buscador de vuelos. Pero tengo la dificultad que no se agrega el carrito.
Les dejo el código por si ven que me falta
Wordpress 4.9.4
Woocommer 3.3.4$post = array( 'post_author' => 1, 'post_content' => '', 'post_status' => "publish", 'post_title' => "Pasaje Aéreo; reserva número ".$controlNumber."", 'post_parent' => '', 'post_type' => "product", ); $wp_error=""; $post_id = wp_insert_post( $post, $wp_error ); do_action('save_post', $post_id, $post); wp_set_object_terms( $post_id, 'AEREO', 'product_cat' ); wp_set_object_terms( $post_id, 'simple', 'product_type'); update_post_meta( $post_id, '_visibility', 'visible' ); update_post_meta( $post_id, '_stock_status', 'instock'); update_post_meta( $post_id, 'total_sales', ''); update_post_meta( $post_id, '_downloadable', 'no'); update_post_meta( $post_id, '_virtual', 'no'); update_post_meta( $post_id, '_regular_price', "$valorTotal" ); update_post_meta( $post_id, '_sale_price', "" ); update_post_meta( $post_id, '_purchase_note', "" ); update_post_meta( $post_id, '_featured', "no" ); update_post_meta( $post_id, '_weight', "" ); update_post_meta( $post_id, '_length', "" ); update_post_meta( $post_id, '_width', "" ); update_post_meta( $post_id, '_height', "" ); update_post_meta( $post_id, '_sku', "$controlNumber"); update_post_meta( $post_id, '_product_attributes', array()); update_post_meta( $post_id, '_sale_price_dates_from', "" ); update_post_meta( $post_id, '_sale_price_dates_to', "" ); update_post_meta( $post_id, '_price', "" ); update_post_meta( $post_id, '_sold_individually', "" ); update_post_meta( $post_id, '_manage_stock', "no" ); update_post_meta( $post_id, '_backorders', "no" ); update_post_meta( $post_id, '_stock', "10" ); // echo $post_id."<br/>"; do_action('edit_post', $post_id, $post); do_action('wp_insert_post', $post_id, $post); $woocommerce->cart->add_to_cart( $post_id ); die(); if ( wp_redirect( "/checkout" ) ) { exit; }
Muchas gracias
La página con la que necesito ayuda: [accede para ver el enlace]
Viendo 1 respuesta (de un total de 1)
Viendo 1 respuesta (de un total de 1)
- El debate ‘insertar producto por código’ está cerrado a nuevas respuestas.