This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Update Post Title from an ACF field value on post save. | |
| * | |
| * Triggers on save, edit or update of published posts. | |
| * Works in "Quick Edit", but not bulk edit. | |
| */ | |
| function sync_acf_post_title($post_id, $post, $update) { | |
| $acf_title = get_field('my_acf_field_name', $post_id); // NOTE: enter the name of the ACF field here |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Put this into your functions.php of your child-theme or custom plugin | |
| * you can create the role with wp-cli by running `wp shell` and running the command: | |
| * add_role('merchant','Merchant',array('read' => true, 'delete_posts' => false) ); | |
| */ | |
| /** | |
| * Step #1: create the field used to store the new sale_price for product_variation and for products | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Adding extra field on New product popup/without popup form | |
| */ | |
| add_action( 'dokan_new_product_after_product_tags','new_product_field',10 ); | |
| function new_product_field(){ ?> | |
| <div class="dokan-form-group"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| add_filter( 'woocommerce_loop_add_to_cart_link', function ( $html, $product ) { | |
| if ( $product && $product->is_type( 'simple' ) && $product->is_purchasable() && $product->is_in_stock() && ! $product->is_sold_individually() ) { | |
| $class = implode( ' ', array_filter( array( | |
| 'button', | |
| 'product_type_' . $product->get_type(), | |
| $product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '', | |
| $product->supports( 'ajax_add_to_cart' ) ? 'ajax_add_to_cart' : '', | |
| ) ) ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Add this to Content Blocks > Hook > No Condition or Location | |
| // Call it through Customizer > Product Archives > Card Options > Enable Content Block Element > Select the Hook name in drop down | |
| if ( is_product() || is_shop() || is_tax( 'product_cat' ) || is_tax( 'product_tag' ) ) { | |
| global $product; | |
| if ( ! $product->is_sold_individually() && 'variable' != $product->product_type && $product->is_purchasable() && $product->is_in_stock() ) { | |
| echo '<div class="dhn-atc-wrap">'; | |
| woocommerce_quantity_input( array( 'min_value' => 1, 'max_value' => $product->backorders_allowed() ? '' : $product->get_stock_quantity() ) ); | |
| echo '<a href="' . esc_url( $product->add_to_cart_url() ) . '" data-quantity="1" class="button product_type_simple add_to_cart_button ajax_add_to_cart" data-product_id="' . esc_attr( $product->get_id() ) . '" aria-label="' . esc_attr( sprintf( __( 'Add to cart: %s', 'woocommerce' ), $product->get_name() ) ) . '" aria-describedby="" rel="nofollow">' . esc_html( $p |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| add_filter( 'woocommerce_loop_add_to_cart_link', function ( $html, $product ) { | |
| if ( is_user_logged_in() && is_shop() && $product && $product->is_type( 'simple' ) && $product->is_purchasable() && $product->is_in_stock() && ! $product->is_sold_individually() ) { | |
| $html = '<form action="' . esc_url( $product->add_to_cart_url() ) . '" class="cart" method="post" enctype="multipart/form-data"><div class="ct-cart-actions">'; | |
| $html .= woocommerce_quantity_input( array(), $product, false ); | |
| $html .= '<button type="submit" class="single_add_to_cart_button button alt" name="add-to-cart" value="' . $product->get_id() . '">' . esc_html( $product->add_to_cart_text() ) . '</button>'; | |
| $html .= '</div></form>'; | |
| } | |
| return $html; | |
| }, 10, 2 ); |
OlderNewer