{"id":9327,"date":"2022-12-21T19:07:15","date_gmt":"2022-12-22T03:07:15","guid":{"rendered":"https:\/\/codedcommerce.com\/?post_type=product&#038;p=9327"},"modified":"2023-10-08T20:15:58","modified_gmt":"2023-10-09T03:15:58","slug":"wp-cli-add-a-custom-command","status":"publish","type":"woo-code","link":"https:\/\/codedcommerce.com\/woo\/wp-cli-add-a-custom-command\/","title":{"rendered":"WP CLI add a custom command"},"content":{"rendered":"\n<pre class=\"wp-block-code language-php\"><code>\/\/ Class Of Commands\nclass CCOM_CLI {\n\n\t\/\/ Gets order Thank You page URL\n\tpublic function get_thankyou_url( $args, $assoc_args ) {\n\t\tif( empty( $args&#91;0] ) ) {\n\t\t\tWP_CLI::error( 'Error: Order ID is missing.' );\n\t\t\treturn;\n\t\t}\n\t\t$order = wc_get_order( $args&#91;0] );\n\t\tWP_CLI::success( $order->get_checkout_order_received_url() );\n\t}\n\n}\n\n\/\/ Hook Into WP-CLI\nadd_action( 'cli_init', function() {\n\n\tWP_CLI::add_command( 'ccom', 'CCOM_CLI' );\n\n} );<\/code><\/pre>\n","protected":false},"template":"","class_list":["post-9327","woo-code","type-woo-code","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/codedcommerce.com\/wp-json\/wp\/v2\/woo-code\/9327","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codedcommerce.com\/wp-json\/wp\/v2\/woo-code"}],"about":[{"href":"https:\/\/codedcommerce.com\/wp-json\/wp\/v2\/types\/woo-code"}],"wp:attachment":[{"href":"https:\/\/codedcommerce.com\/wp-json\/wp\/v2\/media?parent=9327"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}