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 | |
/** | |
* A products field template | |
* Ensure that the 'Products Quantities' field is set to 'One Only' | |
* @since 2.2.0 | |
* @package WooCommerce Product Add Ons Ultimate | |
*/ | |
// Exit if accessed directly | |
if( ! defined( 'ABSPATH' ) ) { |
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
.woocommerce div.product.elementor form.cart.variations_form .woocommerce-variation-add-to-cart, | |
.woocommerce div.product.elementor form.cart:not(.grouped_form):not(.variations_form) { | |
display: block; | |
} | |
.elementor-element ul.pewc-product-extra-groups { | |
padding: 0; | |
} |
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 | |
/** | |
* A checkbox field template | |
* @see https://pluginrepublic.com/documentation/overriding-templates/ | |
* @since 2.0.0 | |
* @package WooCommerce Product Add-Ons Ultimate | |
*/ | |
// Exit if accessed directly | |
if( ! defined( 'ABSPATH' ) ) { |
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 | |
/** | |
* Optionally attach uploaded images to the order email | |
*/ | |
function pewc_attach_images_to_email( $attachments, $id, $order ) { | |
if( ( $id == 'new_order' || $id == 'customer_on_hold_order' ) && get_option( 'pewc_email_images', 'no' ) == 'yes' ) { | |
// Find any attachments | |
$order_items = $order->get_items( 'line_item' ); |
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 if you want to prevent non-required number fields from validating min or max values | |
add_filter( 'pewc_only_validate_number_field_value_if_field_required', '__return_true' ); | |
?> |
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 | |
/** | |
* Display a custom text field | |
* @since 1.0.0 | |
*/ | |
function cfwc_create_custom_field() { | |
woocommerce_wp_text_input( | |
array( | |
'id' => 'custom_text_field_title', | |
'label' => __( 'Custom Text Field Title', 'cfwc' ), |
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 a custom text input field to the product page | |
*/ | |
function plugin_republic_add_text_field() { ?> | |
<div class="pr-field-wrap"> | |
<label for="pr-field"><?php _e( 'Your name', 'plugin-republic' ); ?></label> | |
<input type="text" name='pr-field' id='pr-field' value=''> | |
</div> | |
<?php } |
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 | |
/** | |
* Simple product add to cart | |
* | |
* This template can be overridden by copying it to yourtheme/woocommerce/single-product/add-to-cart/simple.php. | |
* | |
* HOWEVER, on occasion WooCommerce will need to update template files and you | |
* (the theme developer) will need to copy the new files to your theme to | |
* maintain compatibility. We try to do this as little as possible, but it does | |
* happen. When this occurs the version of the template file will be bumped and |
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 | |
/** | |
* Validate our custom text input field value | |
*/ | |
function plugin_republic_add_to_cart_validation( $passed, $product_id, $quantity, $variation_id=null ) { | |
if( empty( $_POST['pr-field'] ) ) { | |
$passed = false; | |
wc_add_notice( __( 'Your name is a required field.', 'plugin-republic' ), 'error' ); | |
} | |
return $passed; |
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 custom cart item data | |
*/ | |
function plugin_republic_add_cart_item_data( $cart_item_data, $product_id, $variation_id ) { | |
if( isset( $_POST['pr-field'] ) ) { | |
$cart_item_data['pr_field'] = sanitize_text_field( $_POST['pr-field'] ); | |
} | |
return $cart_item_data; | |
} |