PluginProbe
Orderable – Restaurant & Food Ordering System / 1.16.0
Orderable – Restaurant & Food Ordering System v1.16.0
0.1.4 0.1.5 0.2.0 1.0.0 1.1.0 1.1.1 1.10.0 1.10.1 1.11.0 1.12.0 1.12.1 1.12.2 1.13.0 1.14.0 1.15.0 1.16.0 1.17.0 1.17.1 1.18.0 1.19.0 1.19.1 1.19.2 1.2.0 1.20.0 1.20.1 All 44 releases
orderable / inc / class-shortcodes.php

class-shortcodes.php in Orderable – Restaurant & Food Ordering System 1.16.0, at inc/class-shortcodes.php

62 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Shortcodes
4 *
5 * @package Orderable/Classes
6 */
7
8 defined( 'ABSPATH' ) || exit;
9
10 /**
11 * Shortcodes class.
12 */
13 class Orderable_Shortcodes {
14
15 /**
16 * Init.
17 */
18 public static function run() {
19 add_shortcode( 'orderable_add_to_cart', array( __CLASS__, 'orderable_add_to_cart' ) );
20 }
21
22 /**
23 * Add to cart shortcode.
24 *
25 * @param array $args Shortcode arguments.
26 *
27 * @return stirng
28 */
29 public static function orderable_add_to_cart( $args ) {
30 $defaults = array(
31 'product_id' => -1,
32 );
33
34 $args = wp_parse_args( $args, $defaults );
35 $product = $args['product_id'];
36
37 if ( $product < 0 ) {
38 global $product;
39 }
40
41 if ( is_numeric( $product ) ) {
42 $product = wc_get_product( $product );
43 }
44
45 if ( empty( $product ) ) {
46 return;
47 }
48
49 ob_start();
50 ?>
51 <div class="orderable-product__actions-button">
52 <?php
53 // Phpcs:ignore -- WordPress.Security.EscapeOutput.OutputNotEscaped.
54 echo Orderable_Products::get_add_to_cart_button( $product, 'orderable-product__add-to-order' );
55 ?>
56 </div>
57 <?php
58
59 return ob_get_clean();
60 }
61 }
62