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 custom item data in the cart | |
*/ | |
function plugin_republic_get_item_data( $item_data, $cart_item_data ) { | |
if( isset( $cart_item_data['pr_field'] ) ) { | |
$item_data[] = array( | |
'key' => __( 'Your name', 'plugin-republic' ), | |
'value' => wc_clean( $cart_item_data['pr_field'] ) | |
); |
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 meta to order | |
*/ | |
function plugin_republic_checkout_create_order_line_item( $item, $cart_item_key, $values, $order ) { | |
if( isset( $values['pr_field'] ) ) { | |
$item->add_meta_data( | |
__( 'Your name', 'plugin-republic' ), | |
$values['pr_field'], | |
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 | |
/** | |
* Add custom cart item data to emails | |
*/ | |
function plugin_republic_order_item_name( $product_name, $item ) { | |
if( isset( $item['pr_field'] ) ) { | |
$product_name .= sprintf( | |
'<ul><li>%s: %s</li></ul>', | |
__( 'Your name', 'plugin_republic' ), | |
esc_html( $item['pr_field'] ) |
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
/** | |
* Remove reference to a specific product ID to apply this to all products | |
* Update the product ID if it differs | |
*/ | |
#product-121 .woocommerce-product-gallery { | |
width: 100%; | |
height: 300px; | |
margin-right: 0; | |
overflow: hidden; | |
} |
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
#product-121 .pewc-item-image_swatch .pewc-item-field-wrapper label.pewc-field-label, | |
#product-121 .pewc-group-heading-wrapper h3 { | |
padding: 1rem; | |
background: #b00025; | |
color: white; | |
margin-bottom: 1rem; | |
font-size: 1.5rem; | |
font-weight: bold; | |
text-transform: uppercase; | |
} |
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 | |
function pr_validate_zipcodes( $fields, $errors ) { | |
// Enter your zip codes in this array | |
$excluded_zips = array( '12345', '23456' ); | |
if( in_array( $fields['shipping_postcode'], $excluded_zips ) ) { | |
$errors->add( 'validation', 'That zipcode is not allowed' ); | |
} | |
} | |
add_action( 'woocommerce_after_checkout_validation', 'pr_validate_zipcodes', 10, 2 ); |
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
.pewc-radio-image-wrapper label input:checked + img, | |
.pewc-checkbox-image-wrapper label input:checked + img { | |
border: 4px solid #ff0000; | |
} |
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 | |
/** | |
* Change the URL that users are redirected to | |
*/ | |
function prefix_redirect_url( $url ) { | |
return 'http://yournewurl.com/'; | |
} | |
add_filter( 'wcmo_redirect_url', 'prefix_redirect_url' ); |
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 | |
/** | |
* Don't remove parent items when a child product is removed from the cart | |
*/ | |
add_filter( 'pewc_do_not_remove_parents', '__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 | |
/** | |
* Get add-on metadata from each line item in the order | |
* @param $order_id | |
* @param $metakey The add-ons metakey (field label), usually prefixed by an underscore | |
*/ | |
function prefix_get_addons_metadata_by_key( $order_id, $metakey=false ) { | |
$order = wc_get_order( $order_id ); | |
$order_line_items = $order->get_items(); |