text_color = $field_args['text_color'] ?? '#FFF'; $this->justification = $field_args['justification'] ?? 'left'; $this->button_color = $field_args['button_color'] ?? '#6246d7'; $this->display_quantity = $field_args['display_quantity'] ?? false; $this->quantity = intval($field_args['quantity'] ?? 1); $this->stock_only = $field_args['stock_only'] ?? true; } /** * Add to cart * * ``` * {woo_add_to_cart_html display_quantity=0 quantity=1 stock_only=1} * // button_color: string * // text_color: string * // display_quantity: 0|1 * // quantity: 0|1 * // stock_only: 0|1 * ``` * * @return string */ public function process(): string { if ( empty($this->product) ) { return ''; } if ( $this->stock_only && !$this->product->is_in_stock() ) { return ''; } $is_variable = $this->product->is_type( 'variable' ); $display_quantity = $this->display_quantity && !$is_variable; $link = !$is_variable ? get_permalink(wc_get_page_id('shop')) : $this->product->get_permalink(); $ajax = !$is_variable ? ' ajax-add-to-cart' : ''; $text = !$is_variable ? __('Add to cart', 'ajax-search-lite') : __('Choose variation', 'ajax-search-lite'); ob_start(); ?>