This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| echo "<pre>"; | |
| print_r($var); | |
| echo "</pre>"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <ul> | |
| <?php | |
| $recent_posts_array = get_posts(); // получаем массив постов | |
| foreach( $recent_posts_array as $recent_post_single ) : // для каждого поста из массива | |
| echo '<a href="' . get_permalink( $recent_post_single ) . '">' . $recent_post_single->post_title . '</a>'; // выводим ссылку | |
| endforeach; // конец цикла | |
| ?> | |
| </ul> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // создаем экземпляр | |
| $my_posts = new WP_Query; | |
| // делаем запрос | |
| $myposts = $my_posts->query( array( | |
| 'post_type' => 'post' | |
| ) ); | |
| // обрабатываем результат |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <ul> | |
| <?php | |
| //По умолчанию метод возвращает массив. Но если передать параметр ('paginate' => 'true'), то вернется объект | |
| //$args = array('paginate' => 'true' ); | |
| $args = array( ); | |
| $orders = wc_get_orders( $args ); | |
| echo $orders[0]->id; //вывод id, первого заказа в массиве | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* | |
| Данный способ сочетает два метода wc_get_orders() и wc_get_order(). | |
| При этом первый метод wc_get_orders (), самостоятельно получает не только список всех заказов, | |
| но и их реквизиты. Но при этом, возвращаеемый массив данных имеет не удобную, вложенную структуру. | |
| Именно поэтому, я использую метод wc_get_order(), который получает данные заказа в виде | |
| более удобного для обхода миссива. | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //Получаем список всех заказов | |
| $args = array( ); | |
| $orders = wc_get_orders( $args ); | |
| //Получаем реквизит заказа, расположенный в массиве данных по адресу [0][billing][billing_first_name] | |
| $datas = $orders[0]->billing_first_name; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function get_order_details($order_id){ | |
| // 1) Get the Order object | |
| $order = wc_get_order( $order_id ); | |
| // OUTPUT | |
| echo '<h3>RAW OUTPUT OF THE ORDER OBJECT: </h3>'; | |
| print_r($order); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $order = wc_get_order( 65 ); | |
| $order_items = $order->get_items(); | |
| foreach( $order_items as $item_id => $item ){ | |
| // методы класса WC_Order_Item | |
| // ID элемента можно получить из ключа массива или так: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Данный способ сочетает два метода wc_get_orders() и wc_get_order(). | |
| При этом первый метод wc_get_orders (), самостоятельно получает не только список всех заказов, | |
| но и их реквизиты. Но при этом, возвращаеемый массив данных имеет не удобную, вложенную структуру. | |
| Именно поэтому, я использую метод wc_get_order(), который получает данные заказа в виде | |
| более удобного для обхода миссива. | |
| Кроме того, метод wc_get_order() посзволяет использовать классы WC_Order_Item и WC_Order_Item_Product | |
| для получения информации по товарам в заказе. Часть этой информации уже есть в всписке заказов, но не вся. | |
| Например, нет характеристик товарв - веса, длинны, ширины, высоты. Нет Артикуля (SKU) и т.д. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace frontend\helpers; | |
| /** | |
| * @author admin | |
| * $text - искомое слово | |
| * $content - основной текст | |
| */ | |
| class HighlightHelper |
OlderNewer