aecorn
Forum Replies Created
-
Forum: Plugins
In reply to: [Woocommerce Hide Add To Cart Button] Still working?Can you try something really lame? Go to wordpress-general settings. Set the date-time settings to Y-m-d H:i:s
Go back to the product and set the expiration date again…
See if that fixes the issue, we two (me and you) might be using different timeformats than the plugin’s authors on our sites…Im guessing that maybe they are using outdated / non-universal methods to call and parse time? Maybe…
Im getting this, which is not the same, but is related.
Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct() [<a href='datetime.--construct'>datetime.--construct</a>]: Failed to parse time string (23/10/2017 20:48) at position 0 (2): Unexpected character'
The result of your $show_hide_datetime is probably “25 octobre 2017 15:47”, which Im guessing is your expiration. $st_dt->format(‘Y-m-d H:i:s’) might not work on this because the format function doesnt understand your french time-format? Maybe? Guessing again.
Forum: Plugins
In reply to: [Woocommerce Hide Add To Cart Button] Still working?This plugin only contains a single php-file which does not make it very hard to search through, what Im doing is duplicating an existing function “hatcb_add_custom_field_into_single”, and changing certain things to meet your criteria. The name of the function also needs to change, otherwise you will get a “collision” between the plugin and your variation of the function.
There is also a function named “hatcb_add_custom_field_into_loop” in the plugin, which regards the view of the product outside the “single product page”, if you need to hide the add to cart also on other pages, take a look at that.
Could you try this variation of the function we’ve been working on? ??
add_action( 'woocommerce_variable_add_to_cart','aecorn_fix_hide_add_to_cart',30 ); function aecorn_fix_hide_add_to_cart(){ global $product; $show_hide_option = get_post_meta( $product->get_id(), 'woo_disable_add_to_cart_checkbox', 'false' ); $show_hide_datetime = get_post_meta( $product->get_id(), 'woo_disable_add_to_cart_date', 'false' ); $st_dt = new DateTime($show_hide_datetime); $set_time = $st_dt->format('Y-m-d H:i:s'); $current_time = current_time( 'mysql' ); if($show_hide_option == 'show_button'){ }else if($show_hide_option == 'disable_button'){ if($set_time>=$current_time){ echo '<style>div.woocommerce-variation-add-to-cart { display: none; };</style>'; } } }
For the nerds out there: the authors of this plugin are calling the product ID in an outdated fashion. The correct way to do it is now: $product->get_id()
Forum: Plugins
In reply to: [Woocommerce Hide Add To Cart Button] Still working?No, im not the developer, that seems to be @9dpi and @tranhoang
I just posted this thread because, like you, I had a client that needed this plugin to work. I think maybe this plugin was created for single products, but the div-class might have changed in the base woocommerce plugin, so their plugin stopped working…I might have to dig through the plugin to look for the piece of code that triggers the expiration date, my client only needed to hide prices on single products permanently, so their needs are not the same as your client’s.
Forum: Plugins
In reply to: [Woocommerce Hide Add To Cart Button] Still working?Depending on the way you are creating the variations, the hook “woocommerce_single_product_summary” might not be triggering, or maybe the if-statement does not ring true “if (is_product())”.
The function I wrote might not work for variations, only single products.Did you say you are using a plugin for the variations, or is this base Woocommerce functionality?
For base woocommerce variations we might need to use something like
add_action( 'woocommerce_variable_add_to_cart', 'aecorn_fix_hide_add_to_cart', 30 );
and
( $product->is_type( 'variable' ) )
To actually check this I need to set up a woocommerce store with variations to test in and that will take some time. Do you think you can work with just pasting the css into the product-descriptions?
Putting together (without testing):
add_action( 'woocommerce_variable_add_to_cart', 'aecorn_fix_hide_add_to_cart', 30 ); function aecorn_fix_hide_add_to_cart(){ global $product; if ( $product->is_type( 'variable' ) ){ $show_hide_option = get_post_meta( $product->get_id(), 'woo_disable_add_to_cart_checkbox', 'false' ); if($show_hide_option == 'disable_button'){ echo '<style>div.woocommerce-variation-add-to-cart { display: none; };</style>'; } } }
Forum: Plugins
In reply to: [Woocommerce Hide Add To Cart Button] Still working?Okey, I think this happens because your variations-plugin is creating different div-classes for your add to cart button etc.
This CSS, should work on your site:
<style> d.woocommerce-variation-add-to-cart { display: none; }</style>
Try experimenting with this, add it to the bottom of your product-description, add it back into the snippet I sent you in the beginning etc. See what works for you.
add_action( 'woocommerce_single_product_summary','aecorn_fix_hide_add_to_cart',11); function aecorn_fix_hide_add_to_cart(){ if (is_product()) { global $product; $show_hide_option = get_post_meta( $product->get_id(), 'woo_disable_add_to_cart_checkbox', 'false' ); if($show_hide_option == 'disable_button'){ echo '<style> d.woocommerce-variation-add-to-cart { display: none; } div.summary.entry-summary form.cart{display:none !important}<br /> div.summary.entry-summary > p.price {display:none !important}</style>'; } } }
To find CSS-selectors, I usually right-click on something in the browser, choose “inspect” or something similar. Then you can find a div-tag that you can try manipulating, and test out som CSS. Learning how to do manipulate CSS, should be your second step in wordpress, after an understanding of basic HTML.
After that, if you feel inclined, start taking a look at PHP.
From there, javascript, including AJAX, and maybe some understanding of databases (SQL). Good luck!I still feel like the plugin-authors should manage to change this plugin to work with hooks and filters, disabling through action-removals, but woocommerce might not have actions for the add-to-cart and quantity separate from the price…
Forum: Plugins
In reply to: [Woocommerce Hide Add To Cart Button] Still working?Hi, can you try going to a product-edit page and swap to the “text” view.
Try pasting this at the bottom of the description:<style> div.summary.entry-summary form.cart{display:none !important}<br /> div.summary.entry-summary > p.price {display:none !important}</style>
Does that do anything?
If not, can you post a link to your site?- This reply was modified 7 years, 1 month ago by aecorn.
Forum: Plugins
In reply to: [Woocommerce Hide Add To Cart Button] Still working?This works for me, still using CSS to hide like the plugin originally uses.
add_action( 'woocommerce_single_product_summary','aecorn_fix_hide_add_to_cart',11); function aecorn_fix_hide_add_to_cart(){ if (is_product()) { global $product; $show_hide_option = get_post_meta( $product->get_id(), 'woo_disable_add_to_cart_checkbox', 'false' ); if($show_hide_option == 'disable_button'){ echo '<style> div.summary.entry-summary form.cart{display:none !important}<br /> div.summary.entry-summary > p.price {display:none !important}<br /></style>'; } } }
Forum: Plugins
In reply to: [Woocommerce Hide Add To Cart Button] Still working?@pictogram
Do you know how to add php code to your functons.php-file?
Try adding this:add_action( 'woocommerce_after_shop_loop_item','aecorn_add_custom_field_into_loop',11); function aecorn_add_custom_field_into_loop(){ if (is_product()) { global $product; $show_hide_option = get_post_meta( $product->id, 'woo_disable_add_to_cart_checkbox', 'false' ); if($show_hide_option == 'disable_button'){ remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart'); remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart'); return WooCommerce::instance(); } } }
This still requires this plugin to work.
If this seems complicated check out this plugin:
https://pagely.com/blog/2015/03/safely-add-code-snippets-to-functions-php/- This reply was modified 7 years, 1 month ago by aecorn.
Ive temporarily fixed this by forcing a reload on window-size change. It is not elegant, because the page visibly reloads. So a better fix than this would be appreciated.
https://stackoverflow.com/questions/5836779/how-can-i-refresh-the-screen-on-browser-resize- This reply was modified 7 years, 2 months ago by aecorn.
Im experiencing similar issues and would like to elaborate.
I have the slider on the right side.
When switching the phone from portrait mode to landscape-mode the contact window appears halfway into the page, refreshing the page fixes the issue.
So if the page is loaded in portrait mode, and the user switches to landscape, that causes the issue.
Im thinking this is caused by the contact-window being visible off-screen, and the horizontal position is being set equal to the the media width or something?A solution might be to have everything invisible if the page is loaded as portrait, and only include visibility on all elements if the page is loaded as portrait mode.
- This reply was modified 7 years, 2 months ago by aecorn.
Forum: Plugins
In reply to: [Thumb Fixer for Social Media] Errors in wp_debugYeah my site is throwing something similar in debug-mode.
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; general_setting_default_fb_thumb has a deprecated constructor in /wp-content/plugins/facebook-thumb-fixer/_facebook-thumb-fixer.php on line 63 Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; general_setting_fb_app_ID has a deprecated constructor in /wp-content/plugins/facebook-thumb-fixer/_facebook-thumb-fixer.php on line 137 Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; general_setting_object_type has a deprecated constructor in /wp-content/plugins/facebook-thumb-fixer/_facebook-thumb-fixer.php on line 158
- This reply was modified 7 years, 2 months ago by aecorn.
Forum: Plugins
In reply to: [Simple Woocommerce Favourites] Removed products still in arrayHm, found a solution using is_in_stock, but this requires the manager to set products to out of stock before throwing them away :/
function simple_print_favourites( $atts ){ $GLOBALS['simple_favourites_running'] = true; extract( shortcode_atts( array( 'user_id' => false ), $atts ) ); $favourites = simple_favourites::get_favourites($user_id); $stack = []; /* check if product is in stock? */ foreach ($favourites as $favs){ $_product = wc_get_product( $favs ); if ($_product->is_in_stock()) { array_push($stack, $favs); } } $fav_output = ''; if(!empty($stack)) : $fav_list = do_shortcode('[products ids="' . implode(',', $favourites) . '" columns="4"]'); $fav_output = "<style> .fav-tittel { display: inherit !important;}</style><div id='simple_favourites_display'>" . $fav_list . "</div>"; /*var_dump ($stack);*/ return $fav_output; endif; unset($GLOBALS['simple_favourites_running']);
Forum: Plugins
In reply to: [Simple Woocommerce Favourites] Postion of Button need to be changed!Hi, Im not the developer, but I think I have an answer for you.
Go into edit-mode on the plugin.
simple-woocommerce-favourites/simple-woocommerce-favourites.phpChange the add_action-line containing simple_add_favourites_button to this:
add_action('woocommerce_after_add_to_cart_form', 'simple_add_favourites_button');
‘woocommerce_after_add_to_cart_form’ is what you need to change it to.
- This reply was modified 7 years, 2 months ago by aecorn.
Forum: Plugins
In reply to: [Woocommerce Hide Add To Cart Button] does this need to be used per product?Adding this to any “custom css”-field in your wordpress installation should do the trick:
div.summary.entry-summary form.cart{display:none !important} div.summary.entry-summary > p.price {display:none !important}
First one hides the purchase-button, the other the price.
- This reply was modified 7 years, 3 months ago by aecorn.
Forum: Reviews
In reply to: [Read More Without Refresh] Very nice.You need to replace some lines in index.php, not add more.
To find them, do a find search for “expand” or similar in index.php of the plugin. The paragraphs are quite similar, I’ve only made minor changes, so you should be able to spot which needs to be replaced.