{"id":430153,"date":"2024-08-24T15:00:28","date_gmt":"2024-08-24T15:00:28","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=430153"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=430153","title":{"rendered":"<span>FAQ \u043f\u043e WooCommerce \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0447\u0430\u0441\u0442\u044c 1<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442! \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0440\u0435\u0448\u0438\u043b \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0447\u0430\u0441\u0442\u043e \u0437\u0430\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 WooCommerce \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432. \u042d\u0442\u043e \u043f\u0435\u0440\u0432\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043c\u043e\u0435\u0433\u043e FAQ, \u0433\u0434\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u0430\u0441\u043f\u0435\u043a\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u0432\u0430\u043c \u043b\u0443\u0447\u0448\u0435 \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u044d\u0442\u043e\u043c \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0435. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c!<\/p>\n<h2>1. \u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u043a\u043e\u0440\u0437\u0438\u043d\u043e\u0439<\/h2>\n<p>1.1. \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u043e\u0432\u0430\u0440\u0430 \u0432 \u043a\u043e\u0440\u0437\u0438\u043d\u0443<\/p>\n<pre><code class=\"php\">&lt;?php $product_id = 123; \/\/ \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043d\u0430 ID \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430 $quantity = 1; \/\/ \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u043e\u0432\u0430\u0440\u0430  WC()-&gt;cart-&gt;add_to_cart($product_id, $quantity);<\/code><\/pre>\n<p>1.2. \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u0442\u043e\u0432\u0430\u0440\u043e\u0432 \u0432 \u043a\u043e\u0440\u0437\u0438\u043d\u0435<\/p>\n<pre><code class=\"php\">&lt;?php $cart_items = WC()-&gt;cart-&gt;get_cart();      foreach ($cart_items as $cart_item_key =&gt; $cart_item) {     $product_id = $cart_item['product_id'];     $quantity = $cart_item['quantity'];     $product_name = $cart_item['data']-&gt;get_name(); \/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430      echo '\u0422\u043e\u0432\u0430\u0440: ' . $product_name . ' - \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e: ' . $quantity . '&lt;br&gt;'; } <\/code><\/pre>\n<p>1.3. \u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0442\u043e\u0432\u0430\u0440\u0430 \u0438\u0437 \u043a\u043e\u0440\u0437\u0438\u043d\u044b<\/p>\n<pre><code class=\"php\">&lt;?php $cart_item_key = 123; \/\/ \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043d\u0430 key \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430 \u0438\u0437 \u043a\u043e\u0440\u0437\u0438\u043d\u044b  WC()-&gt;cart-&gt;remove_cart_item($cart_item_key);<\/code><\/pre>\n<p>1.4. \u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0442\u043e\u0432\u0430\u0440\u0430 \u0432 \u043a\u043e\u0440\u0437\u0438\u043d\u0435<\/p>\n<pre><code class=\"php\">&lt;?php $cart_item_key = 123; \/\/ \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043d\u0430 key \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430 \u0438\u0437 \u043a\u043e\u0440\u0437\u0438\u043d\u044b $quantity = 10; \/\/ \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u043e\u0432\u0430\u0440\u0430  WC()-&gt;cart-&gt;set_quantity($cart_item_key, $quantity);<\/code><\/pre>\n<p>1.5. \u041a\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c <strong>cart_item_key <\/strong>\u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430 \u0432 \u043a\u043e\u0440\u0437\u0438\u043d\u0435<\/p>\n<pre><code class=\"php\">&lt;?php  $product_id = 123; \/\/ \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043d\u0430 \u0432\u0430\u0448 ID \u0442\u043e\u0432\u0430\u0440\u0430  \/\/ \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0432 \u043a\u043e\u0440\u0437\u0438\u043d\u0435 $cart_items = WC()-&gt;cart-&gt;get_cart();  \/\/ \u041f\u0435\u0440\u0435\u0431\u0435\u0440\u0438\u0442\u0435 \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0438 \u043d\u0430\u0439\u0434\u0438\u0442\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 \u043f\u043e product_id $cart_item_key = null;  foreach ( $cart_items as $key =&gt; $item ) {     if ( $item['product_id'] == $product_id ) {         $cart_item_key = $key; \/\/ \u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u0435 \u043a\u043b\u044e\u0447 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430         break; \/\/ \u0412\u044b\u0445\u043e\u0434 \u0438\u0437 \u0446\u0438\u043a\u043b\u0430, \u0435\u0441\u043b\u0438 \u043d\u0430\u0439\u0434\u0435\u043d\u043e \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0435     } }  echo $cart_item_key;<\/code><\/pre>\n<p>1.6. \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u043e\u0432\u0430\u0440\u043e\u0432 \u0432 \u043a\u043e\u0440\u0437\u0438\u043d\u0435<\/p>\n<pre><code class=\"php\">&lt;?php echo WC()-&gt;cart-&gt;get_cart_contents_count();<\/code><\/pre>\n<p>1.7. \u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u043a\u043e\u0440\u0437\u0438\u043d\u044b<\/p>\n<pre><code class=\"php\">&lt;?php echo wc_get_cart_url();<\/code><\/pre>\n<h3>2. \u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0442\u043e\u0432\u0430\u0440\u043e\u043c<\/h3>\n<p>2.1. \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0435<\/p>\n<pre><code class=\"php\">&lt;?php $product_id = 123; \/\/ \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043d\u0430 \u0432\u0430\u0448 ID \u0442\u043e\u0432\u0430\u0440\u0430 $product = wc_get_product( $product_id );  if ( $product ) {     echo '\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430: ' . $product-&gt;get_name();     echo '\u0410\u0440\u0442\u0438\u043a\u0443\u043b: ' . $product-&gt;get_sku();     echo '\u0426\u0435\u043d\u0430: ' . $product-&gt;get_price();     echo '\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435: ' . $product-&gt;get_description(); } else {     echo '\u041f\u0440\u043e\u0434\u0443\u043a\u0442 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d.'; }<\/code><\/pre>\n<p>2.2. \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430<\/p>\n<pre><code class=\"php\">&lt;?php $product = new WC_Product_Simple(); $product-&gt;set_name( '\u0418\u043c\u044f \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430' ); $product-&gt;set_regular_price( '19.99' ); $product-&gt;set_description( '\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430' ); $product-&gt;set_stock_quantity( 100 ); $product-&gt;set_status( 'publish' ); \/\/ \u0418\u043b\u0438 'draft' \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0432 \u0447\u0435\u0440\u043d\u043e\u0432\u0438\u043a\u0430\u0445  $product_id = $product-&gt;save(); \/\/ \u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u043f\u0440\u043e\u0434\u0443\u043a\u0442 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0435\u0433\u043e ID echo '\u0421\u043e\u0437\u0434\u0430\u043d \u043f\u0440\u043e\u0434\u0443\u043a\u0442 \u0441 ID: ' . $product_id;<\/code><\/pre>\n<p>2.3. \u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430<\/p>\n<pre><code class=\"php\">&lt;?php  $product_id = 123; \/\/ \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043d\u0430 \u0432\u0430\u0448 ID \u0442\u043e\u0432\u0430\u0440\u0430 $product = wc_get_product( $product_id );  if ( $product ) {     $product-&gt;set_price( '24.99' ); \/\/ \u041e\u0431\u043d\u043e\u0432\u0438\u0442\u0435 \u0446\u0435\u043d\u0443     $product-&gt;set_stock_quantity( 80 ); \/\/ \u041e\u0431\u043d\u043e\u0432\u0438\u0442\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043d\u0430 \u0441\u043a\u043b\u0430\u0434\u0435     $product-&gt;save(); \/\/ \u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f     echo '\u041f\u0440\u043e\u0434\u0443\u043a\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u0451\u043d.'; } else {     echo '\u041f\u0440\u043e\u0434\u0443\u043a\u0442 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d.'; }<\/code><\/pre>\n<p>2.4.\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430<\/p>\n<pre><code class=\"php\">&lt;?php $product_id = 123; \/\/ \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043d\u0430 \u0432\u0430\u0448 ID \u0442\u043e\u0432\u0430\u0440\u0430  \/\/ \u0423\u0431\u0435\u0434\u0438\u0442\u0435\u0441\u044c, \u0447\u0442\u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 $product = wc_get_product( $product_id ); if ( $product ) {     wp_delete_post( $product_id, true ); \/\/ true \u0434\u043b\u044f \u043f\u043e\u043b\u043d\u043e\u0433\u043e \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u0441\u0442\u0430     echo '\u041f\u0440\u043e\u0434\u0443\u043a\u0442 \u0443\u0434\u0430\u043b\u0451\u043d.'; } else {     echo '\u041f\u0440\u043e\u0434\u0443\u043a\u0442 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d.'; }<\/code><\/pre>\n<p>2.5 \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432<\/p>\n<pre><code class=\"php\">&lt;?php $args = array(     'post_type' =&gt; 'product',     'posts_per_page' =&gt; -1, \/\/ \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0441\u0435 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u044b ); $query = new WP_Query( $args );  if ( $query-&gt;have_posts() ) {     while ( $query-&gt;have_posts() ) {         $query-&gt;the_post();         $product = wc_get_product( get_the_ID() );         echo 'ID: ' . $product-&gt;get_id() . ' \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435: ' . $product-&gt;get_name() . '&lt;br&gt;';     }     wp_reset_postdata(); } else {     echo '\u041f\u0440\u043e\u0434\u0443\u043a\u0442\u044b \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u044b.'; }<\/code><\/pre>\n<h3>3. \u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0437\u0430\u043a\u0430\u0437\u043e\u043c<\/h3>\n<p>3.1. \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u0437\u0430\u043a\u0430\u0437\u043e\u0432<\/p>\n<pre><code class=\"php\">&lt;?php  $status = 'completed';  $args = array(   'status' =&gt; $status,   'limit' =&gt; -1, \/\/ \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0441\u0435 \u0437\u0430\u043a\u0430\u0437\u044b );  $orders = wc_get_orders($args);  foreach ($orders as $order) {     echo '\u0417\u0430\u043a\u0430\u0437 #: ' . $order-&gt;get_id() . '&lt;br&gt;'; }<\/code><\/pre>\n<p>3.2. \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c \u0437\u0430\u043a\u0430\u0437\u0435<\/p>\n<pre><code class=\"php\">&lt;?php $order_id = 123; \/\/ \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043d\u0430 \u0432\u0430\u0448 ID \u0437\u0430\u043a\u0430\u0437\u0430 $order = wc_get_order($order_id);  if ($order) {     echo '\u0417\u0430\u043a\u0430\u0437 ID: ' . $order-&gt;get_id() . '&lt;br&gt;';     echo '\u0421\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0437\u0430\u043a\u0430\u0437\u0430: ' . $order-&gt;get_status() . '&lt;br&gt;';     echo '\u0421\u0443\u043c\u043c\u0430 \u0437\u0430\u043a\u0430\u0437\u0430: ' . $order-&gt;get_total() . '&lt;br&gt;'; } else {     echo '\u0417\u0430\u043a\u0430\u0437 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d.'; }<\/code><\/pre>\n<p>3.3. \u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u0442\u0443\u0441\u0430 \u0437\u0430\u043a\u0430\u0437\u0430<\/p>\n<p><strong>pending<\/strong> \u2014 \u041e\u0436\u0438\u0434\u0430\u043d\u0438\u0435 \u043e\u043f\u043b\u0430\u0442\u044b<br \/><strong>processing<\/strong> \u2014 \u0412 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435<br \/><strong>on-hold<\/strong> \u2014 \u041d\u0430 \u0443\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0438<br \/><strong>completed<\/strong> \u2014 \u0417\u0430\u0432\u0435\u0440\u0448\u0451\u043d<br \/><strong>cancelled<\/strong> \u2014 \u041e\u0442\u043c\u0435\u043d\u0451\u043d<br \/><strong>refunded<\/strong> \u2014 \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0451\u043d<\/p>\n<pre><code class=\"php\">&lt;?php $order_id = 123; \/\/ \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043d\u0430 \u0432\u0430\u0448 ID \u0437\u0430\u043a\u0430\u0437\u0430 $order = wc_get_order( $order_id );  if ( $order ) {     $new_status = 'completed'; \/\/ \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043d\u0430 \u043d\u0443\u0436\u043d\u044b\u0439 \u0432\u0430\u043c \u0441\u0442\u0430\u0442\u0443\u0441 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, 'pending', 'processing', 'on-hold', 'completed', 'cancelled', 'refunded', 'failed')     $order-&gt;update_status( $new_status, '\u0421\u0442\u0430\u0442\u0443\u0441 \u0437\u0430\u043a\u0430\u0437\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0451\u043d \u043d\u0430 ' . $new_status );     echo '\u0421\u0442\u0430\u0442\u0443\u0441 \u0437\u0430\u043a\u0430\u0437\u0430 \u0431\u044b\u043b \u0438\u0437\u043c\u0435\u043d\u0451\u043d \u043d\u0430 ' . $new_status; } else {     echo '\u0417\u0430\u043a\u0430\u0437 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d.'; }<\/code><\/pre>\n<p>3.4. \u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u043a\u0430\u0437\u0430<\/p>\n<pre><code class=\"php\">&lt;?php $order_id = 123; \/\/ \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043d\u0430 \u0432\u0430\u0448 ID \u0437\u0430\u043a\u0430\u0437\u0430 $order = wc_get_order($order_id);  if ($order) {     $order-&gt;delete(true);     echo '\u0417\u0430\u043a\u0430\u0437 ID: ' . $order_id . ' \u0431\u044b\u043b \u0443\u0434\u0430\u043b\u0451\u043d.'; } else {     echo '\u0417\u0430\u043a\u0430\u0437 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d.'; }<\/code><\/pre>\n<p>3.5. \u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0435 \u0432 \u0437\u0430\u043a\u0430\u0437\u0435<\/p>\n<pre><code class=\"php\">&lt;?php $order_id = 123; \/\/ \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043d\u0430 \u0432\u0430\u0448 ID \u0437\u0430\u043a\u0430\u0437\u0430 $order = wc_get_order($order_id);  if ($order) {     $order-&gt;set_billing_address_1('new_address');     $order-&gt;set_billing_city('new_city');     $order-&gt;set_billing_postcode('new_postcode');     $order-&gt;save();     echo '\u0410\u0434\u0440\u0435\u0441 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0451\u043d \u0434\u043b\u044f \u0437\u0430\u043a\u0430\u0437\u0430 ID: ' . $order_id; } else {     echo '\u0417\u0430\u043a\u0430\u0437 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d.'; }<\/code><\/pre>\n<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u0438\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441\u0432\u043e\u0438\u043c \u043e\u043f\u044b\u0442\u043e\u043c \u043f\u043e \u044d\u0442\u043e\u0439 \u0442\u0435\u043c\u0435, \u043d\u0435 \u0441\u0442\u0435\u0441\u043d\u044f\u0439\u0442\u0435\u0441\u044c \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438! \u042f \u0431\u0443\u0434\u0443 \u0440\u0430\u0434 \u0443\u0441\u043b\u044b\u0448\u0430\u0442\u044c \u0432\u0430\u0448\u0435 \u043c\u043d\u0435\u043d\u0438\u0435. \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u0430\u0448\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435!<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/838242\/\"> https:\/\/habr.com\/ru\/articles\/838242\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442! \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0440\u0435\u0448\u0438\u043b \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0447\u0430\u0441\u0442\u043e \u0437\u0430\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 WooCommerce \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432. \u042d\u0442\u043e \u043f\u0435\u0440\u0432\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043c\u043e\u0435\u0433\u043e FAQ, \u0433\u0434\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u0430\u0441\u043f\u0435\u043a\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u0432\u0430\u043c \u043b\u0443\u0447\u0448\u0435 \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u044d\u0442\u043e\u043c \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0435. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c!<\/p>\n<h2>1. \u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u043a\u043e\u0440\u0437\u0438\u043d\u043e\u0439<\/h2>\n<p>1.1. \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u043e\u0432\u0430\u0440\u0430 \u0432 \u043a\u043e\u0440\u0437\u0438\u043d\u0443<\/p>\n<pre><code class=\"php\">&lt;?php $product_id = 123; \/\/ \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043d\u0430 ID \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430 $quantity = 1; \/\/ \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u043e\u0432\u0430\u0440\u0430  WC()-&gt;cart-&gt;add_to_cart($product_id, $quantity);<\/code><\/pre>\n<p>1.2. \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u0442\u043e\u0432\u0430\u0440\u043e\u0432 \u0432 \u043a\u043e\u0440\u0437\u0438\u043d\u0435<\/p>\n<pre><code class=\"php\">&lt;?php $cart_items = WC()-&gt;cart-&gt;get_cart();      foreach ($cart_items as $cart_item_key =&gt; $cart_item) {     $product_id = $cart_item['product_id'];     $quantity = $cart_item['quantity'];     $product_name = $cart_item['data']-&gt;get_name(); \/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430      echo '\u0422\u043e\u0432\u0430\u0440: ' . $product_name . ' - \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e: ' . $quantity . '&lt;br&gt;'; } <\/code><\/pre>\n<p>1.3. \u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0442\u043e\u0432\u0430\u0440\u0430 \u0438\u0437 \u043a\u043e\u0440\u0437\u0438\u043d\u044b<\/p>\n<pre><code class=\"php\">&lt;?php $cart_item_key = 123; \/\/ \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043d\u0430 key \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430 \u0438\u0437 \u043a\u043e\u0440\u0437\u0438\u043d\u044b  WC()-&gt;cart-&gt;remove_cart_item($cart_item_key);<\/code><\/pre>\n<p>1.4. \u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0442\u043e\u0432\u0430\u0440\u0430 \u0432 \u043a\u043e\u0440\u0437\u0438\u043d\u0435<\/p>\n<pre><code class=\"php\">&lt;?php $cart_item_key = 123; \/\/ \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043d\u0430 key \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430 \u0438\u0437 \u043a\u043e\u0440\u0437\u0438\u043d\u044b $quantity = 10; \/\/ \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u043e\u0432\u0430\u0440\u0430  WC()-&gt;cart-&gt;set_quantity($cart_item_key, $quantity);<\/code><\/pre>\n<p>1.5. \u041a\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c <strong>cart_item_key <\/strong>\u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430 \u0432 \u043a\u043e\u0440\u0437\u0438\u043d\u0435<\/p>\n<pre><code class=\"php\">&lt;?php  $product_id = 123; \/\/ \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043d\u0430 \u0432\u0430\u0448 ID \u0442\u043e\u0432\u0430\u0440\u0430  \/\/ \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0432 \u043a\u043e\u0440\u0437\u0438\u043d\u0435 $cart_items = WC()-&gt;cart-&gt;get_cart();  \/\/ \u041f\u0435\u0440\u0435\u0431\u0435\u0440\u0438\u0442\u0435 \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0438 \u043d\u0430\u0439\u0434\u0438\u0442\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 \u043f\u043e product_id $cart_item_key = null;  foreach ( $cart_items as $key =&gt; $item ) {     if ( $item['product_id'] == $product_id ) {         $cart_item_key = $key; \/\/ \u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u0435 \u043a\u043b\u044e\u0447 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430         break; \/\/ \u0412\u044b\u0445\u043e\u0434 \u0438\u0437 \u0446\u0438\u043a\u043b\u0430, \u0435\u0441\u043b\u0438 \u043d\u0430\u0439\u0434\u0435\u043d\u043e \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0435     } }  echo $cart_item_key;<\/code><\/pre>\n<p>1.6. \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u043e\u0432\u0430\u0440\u043e\u0432 \u0432 \u043a\u043e\u0440\u0437\u0438\u043d\u0435<\/p>\n<pre><code class=\"php\">&lt;?php echo WC()-&gt;cart-&gt;get_cart_contents_count();<\/code><\/pre>\n<p>1.7. \u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u043a\u043e\u0440\u0437\u0438\u043d\u044b<\/p>\n<pre><code class=\"php\">&lt;?php echo wc_get_cart_url();<\/code><\/pre>\n<h3>2. \u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0442\u043e\u0432\u0430\u0440\u043e\u043c<\/h3>\n<p>2.1. \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0435<\/p>\n<pre><code class=\"php\">&lt;?php $product_id = 123; \/\/ \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043d\u0430 \u0432\u0430\u0448 ID \u0442\u043e\u0432\u0430\u0440\u0430 $product = wc_get_product( $product_id );  if ( $product ) {     echo '\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430: ' . $product-&gt;get_name();     echo '\u0410\u0440\u0442\u0438\u043a\u0443\u043b: ' . $product-&gt;get_sku();     echo '\u0426\u0435\u043d\u0430: ' . $product-&gt;get_price();     echo '\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435: ' . $product-&gt;get_description(); } else {     echo '\u041f\u0440\u043e\u0434\u0443\u043a\u0442 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d.'; }<\/code><\/pre>\n<p>2.2. \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430<\/p>\n<pre><code class=\"php\">&lt;?php $product = new WC_Product_Simple(); $product-&gt;set_name( '\u0418\u043c\u044f \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430' ); $product-&gt;set_regular_price( '19.99' ); $product-&gt;set_description( '\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430' ); $product-&gt;set_stock_quantity( 100 ); $product-&gt;set_status( 'publish' ); \/\/ \u0418\u043b\u0438 'draft' \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0432 \u0447\u0435\u0440\u043d\u043e\u0432\u0438\u043a\u0430\u0445  $product_id = $product-&gt;save(); \/\/ \u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u043f\u0440\u043e\u0434\u0443\u043a\u0442 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0435\u0433\u043e ID echo '\u0421\u043e\u0437\u0434\u0430\u043d \u043f\u0440\u043e\u0434\u0443\u043a\u0442 \u0441 ID: ' . $product_id;<\/code><\/pre>\n<p>2.3. \u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430<\/p>\n<pre><code class=\"php\">&lt;?php  $product_id = 123; \/\/ \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043d\u0430 \u0432\u0430\u0448 ID \u0442\u043e\u0432\u0430\u0440\u0430 $product = wc_get_product( $product_id );  if ( $product ) {     $product-&gt;set_price( '24.99' ); \/\/ \u041e\u0431\u043d\u043e\u0432\u0438\u0442\u0435 \u0446\u0435\u043d\u0443     $product-&gt;set_stock_quantity( 80 ); \/\/ \u041e\u0431\u043d\u043e\u0432\u0438\u0442\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043d\u0430 \u0441\u043a\u043b\u0430\u0434\u0435     $product-&gt;save(); \/\/ \u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f     echo '\u041f\u0440\u043e\u0434\u0443\u043a\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u0451\u043d.'; } else {     echo '\u041f\u0440\u043e\u0434\u0443\u043a\u0442 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d.'; }<\/code><\/pre>\n<p>2.4.\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430<\/p>\n<pre><code class=\"php\">&lt;?php $product_id = 123; \/\/ \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043d\u0430 \u0432\u0430\u0448 ID \u0442\u043e\u0432\u0430\u0440\u0430  \/\/ \u0423\u0431\u0435\u0434\u0438\u0442\u0435\u0441\u044c, \u0447\u0442\u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 $product = wc_get_product( $product_id ); if ( $product ) {     wp_delete_post( $product_id, true ); \/\/ true \u0434\u043b\u044f \u043f\u043e\u043b\u043d\u043e\u0433\u043e \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u0441\u0442\u0430     echo '\u041f\u0440\u043e\u0434\u0443\u043a\u0442 \u0443\u0434\u0430\u043b\u0451\u043d.'; } else {     echo '\u041f\u0440\u043e\u0434\u0443\u043a\u0442 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d.'; }<\/code><\/pre>\n<p>2.5 \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432<\/p>\n<pre><code class=\"php\">&lt;?php $args = array(     'post_type' =&gt; 'product',     'posts_per_page' =&gt; -1, \/\/ \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0441\u0435 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u044b ); $query = new WP_Query( $args );  if ( $query-&gt;have_posts() ) {     while ( $query-&gt;have_posts() ) {         $query-&gt;the_post();         $product = wc_get_product( get_the_ID() );         echo 'ID: ' . $product-&gt;get_id() . ' \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435: ' . $product-&gt;get_name() . '&lt;br&gt;';     }     wp_reset_postdata(); } else {     echo '\u041f\u0440\u043e\u0434\u0443\u043a\u0442\u044b \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u044b.'; }<\/code><\/pre>\n<h3>3. \u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0437\u0430\u043a\u0430\u0437\u043e\u043c<\/h3>\n<p>3.1. \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u0437\u0430\u043a\u0430\u0437\u043e\u0432<\/p>\n<pre><code class=\"php\">&lt;?php  $status = 'completed';  $args = array(   'status' =&gt; $status,   'limit' =&gt; -1, \/\/ \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0441\u0435 \u0437\u0430\u043a\u0430\u0437\u044b );  $orders = wc_get_orders($args);  foreach ($orders as $order) {     echo '\u0417\u0430\u043a\u0430\u0437 #: ' . $order-&gt;get_id() . '&lt;br&gt;'; }<\/code><\/pre>\n<p>3.2. \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c \u0437\u0430\u043a\u0430\u0437\u0435<\/p>\n<pre><code class=\"php\">&lt;?php $order_id = 123; \/\/ \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043d\u0430 \u0432\u0430\u0448 ID \u0437\u0430\u043a\u0430\u0437\u0430 $order = wc_get_order($order_id);  if ($order) {     echo '\u0417\u0430\u043a\u0430\u0437 ID: ' . $order-&gt;get_id() . '&lt;br&gt;';     echo '\u0421\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0437\u0430\u043a\u0430\u0437\u0430: ' . $order-&gt;get_status() . '&lt;br&gt;';     echo '\u0421\u0443\u043c\u043c\u0430 \u0437\u0430\u043a\u0430\u0437\u0430: ' . $order-&gt;get_total() . '&lt;br&gt;'; } else {     echo '\u0417\u0430\u043a\u0430\u0437 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d.'; }<\/code><\/pre>\n<p>3.3. \u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u0442\u0443\u0441\u0430 \u0437\u0430\u043a\u0430\u0437\u0430<\/p>\n<p><strong>pending<\/strong> \u2014 \u041e\u0436\u0438\u0434\u0430\u043d\u0438\u0435 \u043e\u043f\u043b\u0430\u0442\u044b<br \/><strong>processing<\/strong> \u2014 \u0412 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435<br \/><strong>on-hold<\/strong> \u2014 \u041d\u0430 \u0443\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0438<br \/><strong>completed<\/strong> \u2014 \u0417\u0430\u0432\u0435\u0440\u0448\u0451\u043d<br \/><strong>cancelled<\/strong> \u2014 \u041e\u0442\u043c\u0435\u043d\u0451\u043d<br \/><strong>refunded<\/strong> \u2014 \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0451\u043d<\/p>\n<pre><code class=\"php\">&lt;?php $order_id = 123; \/\/ \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043d\u0430 \u0432\u0430\u0448 ID \u0437\u0430\u043a\u0430\u0437\u0430 $order = wc_get_order( $order_id );  if ( $order ) {     $new_status = 'completed'; \/\/ \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043d\u0430 \u043d\u0443\u0436\u043d\u044b\u0439 \u0432\u0430\u043c \u0441\u0442\u0430\u0442\u0443\u0441 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, 'pending', 'processing', 'on-hold', 'completed', 'cancelled', 'refunded', 'failed')     $order-&gt;update_status( $new_status, '\u0421\u0442\u0430\u0442\u0443\u0441 \u0437\u0430\u043a\u0430\u0437\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0451\u043d \u043d\u0430 ' . $new_status );     echo '\u0421\u0442\u0430\u0442\u0443\u0441 \u0437\u0430\u043a\u0430\u0437\u0430 \u0431\u044b\u043b \u0438\u0437\u043c\u0435\u043d\u0451\u043d \u043d\u0430 ' . $new_status; } else {     echo '\u0417\u0430\u043a\u0430\u0437 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d.'; }<\/code><\/pre>\n<p>3.4. \u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u043a\u0430\u0437\u0430<\/p>\n<pre><code class=\"php\">&lt;?php $order_id = 123; \/\/ \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043d\u0430 \u0432\u0430\u0448 ID \u0437\u0430\u043a\u0430\u0437\u0430 $order = wc_get_order($order_id);  if ($order) {     $order-&gt;delete(true);     echo '\u0417\u0430\u043a\u0430\u0437 ID: ' . $order_id . ' \u0431\u044b\u043b \u0443\u0434\u0430\u043b\u0451\u043d.'; } else {     echo '\u0417\u0430\u043a\u0430\u0437 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d.'; }<\/code><\/pre>\n<p>3.5. \u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0435 \u0432 \u0437\u0430\u043a\u0430\u0437\u0435<\/p>\n<pre><code class=\"php\">&lt;?php $order_id = 123; \/\/ \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043d\u0430 \u0432\u0430\u0448 ID \u0437\u0430\u043a\u0430\u0437\u0430 $order = wc_get_order($order_id);  if ($order) {     $order-&gt;set_billing_address_1('new_address');     $order-&gt;set_billing_city('new_city');     $order-&gt;set_billing_postcode('new_postcode');     $order-&gt;save();     echo '\u0410\u0434\u0440\u0435\u0441 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0451\u043d \u0434\u043b\u044f \u0437\u0430\u043a\u0430\u0437\u0430 ID: ' . $order_id; } else {     echo '\u0417\u0430\u043a\u0430\u0437 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d.'; }<\/code><\/pre>\n<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u0438\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441\u0432\u043e\u0438\u043c \u043e\u043f\u044b\u0442\u043e\u043c \u043f\u043e \u044d\u0442\u043e\u0439 \u0442\u0435\u043c\u0435, \u043d\u0435 \u0441\u0442\u0435\u0441\u043d\u044f\u0439\u0442\u0435\u0441\u044c \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438! \u042f \u0431\u0443\u0434\u0443 \u0440\u0430\u0434 \u0443\u0441\u043b\u044b\u0448\u0430\u0442\u044c \u0432\u0430\u0448\u0435 \u043c\u043d\u0435\u043d\u0438\u0435. \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u0430\u0448\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435!<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/838242\/\"> https:\/\/habr.com\/ru\/articles\/838242\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-430153","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/430153","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=430153"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/430153\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=430153"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=430153"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=430153"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}