jQuery(document).ready(function ($) {
$('a.modal-product-link').on('click', function () {
jQuery(document).ready(function ($) {
$(document).on('click', 'a.modal-product-link', function () {
if ( 'name_list' == $orderby_value ) {
$args['orderby'] = 'meta_value_num name';
$args['order'] = 'ASC'; // (или 'DESC';)
$args['meta_key'] = '_price';
}
$qorder = wc_create_order();
if ( 0 === $params['type'] ) { /* simple */
$product = wc_get_product( $params['id'] );
$item_id = $qorder->add_product( $product, $params['qty'] );
} elseif ( 1 === $params['type'] ) { /* variable */
$variations_array = array();
$var_product = new WC_Product_Variation( $params['var_id'] );
$variations_array['variation'] = array(
$params['attr_name'] => $params['attr_value'],
);
$item_id = $qorder->add_product( $var_product, $params['qty'], $variations_array );
}
$qorder->set_address( $address, 'billing' );
$qorder->set_address( $address, 'shipping' );
$qorder->calculate_totals();
wc_reduce_stock_levels( $qorder->get_id() );
$qorder->update_status( 'processing' );
echo 'Спасибо за заказ';
php -v
/**
* Checks the product type.
*
* Backwards compatibility with downloadable/virtual.
*
* @param string|array $type Array or string of types.
* @return bool
*/
public function is_type( $type ) {
return ( $this->get_type() === $type || ( is_array( $type ) && in_array( $this->get_type(), $type, true ) ) );
}
/**
* Get internal type.
*
* @return string
*/
public function get_type() {
return 'variation';
}
if ( $product->is_type( 'variation' ))
/woocommerce/templates/emails
email-order-items.php
// allow other plugins to add additional product information here.
do_action( 'woocommerce_order_item_meta_end', $item_id, $item, $order, $plain_text );
WC_Product
. Да, долго, тяжело, надо разбивать но блоки если много товаров. Зато надежно.$product = wc_get_product($id);
... делаем что то
$product->save();
stock_status
и в таблицу ..._wc_product_meta_lookup