admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'awooc-nonce' ), ) ); } /** * Вывод всплывающего окна * * @since 1.8.0 */ public function popup_window_html() { if ( ! is_product() ) { return; } $elements = get_option( 'woocommerce_awooc_select_item' ); if ( ! is_array( $elements ) ) { return; } include AWOOC_PLUGIN_DIR . 'includes/view/html-popup-window.php'; } /** * Включение режима каталога в зависимости от настроек * * @return bool */ public function disable_add_to_cart() { $mode_catalog = get_option( 'woocommerce_awooc_mode_catalog' ); if ( 'dont_show_add_to_card' === $mode_catalog ) { if ( is_product() ) { return true; } return false; } else { return true; } } /** * Вывод кнопки Заказать в зависимости от настроек * * @since 1.8.0 */ public function add_custom_button() { global $product; $show_add_to_card = get_option( 'woocommerce_awooc_mode_catalog' ); switch ( $show_add_to_card ) { case 'dont_show_add_to_card': add_filter( 'woocommerce_product_add_to_cart_text', array( $this, 'disable_text_add_to_cart_to_related' ) ); add_filter( 'woocommerce_product_add_to_cart_url', array( $this, 'disable_url_add_to_cart_to_related' ) ); $this->hide_button_add_to_card(); if ( is_product() ) { awooc_html_custom_add_to_cart(); } break; case 'show_add_to_card': $this->show_button_add_to_card(); if ( is_product() ) { awooc_html_custom_add_to_cart(); } break; case 'in_stock_add_to_card': if ( $product->is_on_backorder() || 0 === $product->get_price() || ! $product->get_price() || ! $product->is_in_stock() ) { $this->hide_button_add_to_card(); awooc_html_custom_add_to_cart(); } break; } } /** * Скрытие кнопки купить * * @since 1.8.0 * @since 1.8.3 * * @return mixed|void */ public function hide_button_add_to_card() { ob_start(); ?> get_id() ); } return $url; } /** * Замена текста на кнопках в похожих товарах на страницах товарах * * @since 1.8.0 * * @param $text * * @return string */ public function disable_text_add_to_cart_to_related( $text ) { if ( is_product() ) { $text = __( 'Read more', 'woocommerce' ); } return $text; } }