Posts

Showing posts with the label woocommerce

WooCommerce woocommerce_admin_settings_sanitize_option use

WooCommerce woocommerce_admin_settings_sanitize_option use I'm currently using the action woocommerce_update_option_X to save the settings of my plugin settings page. However, the following error occurs: woocommerce_update_option_X action is deprecated, use woocommerce_admin_settings_sanitize_option filter instead But when I try to find information on that filter, I can't figure out how to use it in my case. In my settings I have a table with fields that has to be saved. The table looks like this: ... <tbody> <?php $max_settings = get_option('max_settings',array()); foreach ( $max_settings as $data ) { ?> <tr> <td><input type="text" value="<?php echo esc_attr( $data['var'] ) ?>" name="max_settings[var]" /></td> <td><input type="text" value="<?php echo esc_attr( $data['productid'] ) ?>" name="max_settings[productid]" /></td> ...

Product attribute empty value from order item in Woocommerce 3

Image
Product attribute empty value from order item in Woocommerce 3 I know that there are a lot of questions already for that matter but im not able to figure out how to get a custom product attribute from an woocommerce order. here is what i have try: $order = wc_get_order( $order_id ); $order_data = $order->get_data(); foreach ($order->get_items() as $item_key => $item_values) { $product = $item_values->get_product(); // Get the product $product_id = $item_values->get_product_id(); // the Product id $tokens = get_post_meta($product_id, 'Tokens', true); } I have also try: $tokens = $product->get_attribute( 'Tokens' ); and $tokens = array_shift( wc_get_product_terms( $product_id, 'Tokens', array( 'fields' => 'names' ) ) ); My custom product attribute has the name " Tokens " and the value 5000 but im getting an empty return, what am i doing wrong? That can h...

Loop to return all Woocommerce product tags in alphabetical order

Loop to return all Woocommerce product tags in alphabetical order i am trying to make a loop in WordPress for woocommerce theme to get out all product tags in alphabetical order in a simple way "heading with A below it all tags starts with A letter etc." i am using the code but its return null <?php $tags = get_tags(); $html = '<div class="post_tags">'; foreach ( $tags as $tag ) { $tag_link = get_tag_link( $tag->term_id ); $html .= "<a href='{$tag_link}' title='{$tag->name} Tag' class='{$tag- >slug}'>"; $html .= "{$tag->name}</a>"; } $html .= '</div>'; echo $html; ?> 2 Answers 2 You can also use a WP_Term_Query with the Woocommerce product tag custom taxonomy, to get all related terms alphabetically by letter: WP_Term_Query $taxonomy = 'product_tag...

Renaming WooCommerce Order Status

Renaming WooCommerce Order Status I would like to rename the WooCommerce order status from "Completed" to "Order Received". I can edit the script below located in wc-order-functions.php, but I would prefer not to modify any core files or use a plugin. Is it possible to override woocoomerce functions with scripts in child theme's functions.php file? functions.php function wc_get_order_statuses() { $order_statuses = array( 'wc-pending' => _x( 'Pending Payment', 'Order status', 'woocommerce' ), 'wc-processing' => _x( 'Processing', 'Order status', 'woocommerce' ), 'wc-on-hold' => _x( 'On Hold', 'Order status', 'woocommerce' ), 'wc-completed' => _x( 'Completed', 'Order status', 'woocommerce' ), 'wc-cancelled' => _x( 'Cancelled', 'Order status', 'woocommerce' ), ...

Change the text of 'View cart' button

Change the text of 'View cart' button Iam using a woocommerce plugin but I got an problem on how to change the text of the view cart button hope there is a one who can help with my problem this is my site this is the image of the text that i want to change the image how can i edit it? all suggestion are appreciated. 4 Answers 4 Add the following to your functions.php file. /** * Change text strings * * @link http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext */ function my_text_strings( $translated_text, $text, $domain ) { switch ( strtolower( $translated_text ) ) { case 'View Cart' : $translated_text = __( 'View Shopping Cart', 'woocommerce' ); break; } return $translated_text; } add_filter( 'gettext', 'my_text_strings', 20, 3 ); This will change View Cart to View Shopping Cart ...