id = 'per_product'; $this->desc = __( 'Per Product', 'add-to-cart-button-labels-for-woocommerce' ); parent::__construct(); if ( 'yes' === get_option( 'alg_wc_add_to_cart_button_labels_per_product_enabled', 'no' ) ) { add_action( 'add_meta_boxes', array( $this, 'add_custom_add_to_cart_meta_box' ) ); add_action( 'save_post_product', array( $this, 'save_custom_add_to_cart_meta_box' ), PHP_INT_MAX, 2 ); } } /** * save_custom_add_to_cart_meta_box. * * @version 1.0.0 * @since 1.0.0 */ function save_custom_add_to_cart_meta_box( $post_id, $post ) { // Check that we are saving with custom add to cart metabox displayed. if ( ! isset( $_POST['alg_wc_custom_add_to_cart_save_post'] ) ) { return; } update_post_meta( $post_id, '_' . 'alg_wc_add_to_cart_button_labels_' . 'single', $_POST[ 'alg_wc_add_to_cart_button_labels_' . 'single' ] ); update_post_meta( $post_id, '_' . 'alg_wc_add_to_cart_button_labels_' . 'archive', $_POST[ 'alg_wc_add_to_cart_button_labels_' . 'archive' ] ); } /** * add_custom_add_to_cart_meta_box. * * @version 1.0.0 * @since 1.0.0 */ function add_custom_add_to_cart_meta_box() { add_meta_box( 'alg-wc-custom-add-to-cart', __( 'Custom Add to Cart Button Labels', 'add-to-cart-button-labels-for-woocommerce' ), array( $this, 'create_custom_add_to_cart_meta_box' ), 'product', 'normal', 'high' ); } /** * create_custom_add_to_cart_meta_box. * * @version 1.2.0 * @since 1.0.0 */ function create_custom_add_to_cart_meta_box() { $current_post_id = get_the_ID(); $options = array( 'single' => __( 'Single product view', 'add-to-cart-button-labels-for-woocommerce' ), 'archive' => __( 'Product category (archive) view', 'add-to-cart-button-labels-for-woocommerce' ), ); $html = '
| ' . $option_desc . ' | '; $html .= ''; $html .= ''; $html .= ' | '; $html .= '
|---|