Dekadinious
Forum Replies Created
-
Forum: Developing with WordPress
In reply to: wp_localize_script and cachingI would think server side caching is the most relevant. I am basically trying to integrate the Snapchat Pixel in a smart and minimal way. Snapchat wants user email and phone number when they are logged in, and they want it on every page load. So I am using wp_localize_script to avoid AJAX-calls for every page load. I don’t know if that’s necessary to avoid or not?
I am looking through the official Facebook Pixel for WordPress plugin to find some hits as to how they do it. I see that they also print JavaScript to the page with my email and phone number. This JavaScript is not present in incognito, and I would assume that the values are different for different people.
I see they use wc_enqueue_js some places, but I haven’t quite been able to track how they deal with caching etc. I can’t see that they use any AJAX-calls to get that information.
So the question is really: How do I give a JavaScript-file or the browser dynamic sensitive info that should not be cached between users? And how to I do it in a resource sparing way?
Forum: Developing with WordPress
In reply to: Can I remove password notification emails like this?Thanks for the reply!
Just to be safe: The only thing this snippet does is remove the action that sends that particular email, correct? There are no other native WP-functions connected to this?
Would you please advice on this topic?
Forum: Plugins
In reply to: [WooCommerce] Change after Add To Cart button text sizeYes, you can use one of these hooks to add the same action:
https://www.businessbloomer.com/woocommerce-visual-hook-guide-checkout-page/
You don’t need to create the function again, just add a new line with:
add_action('YOUR_CHOSEN_HOOK', 'show_content_after_add_to_cart');Forum: Plugins
In reply to: [WooCommerce] Change after Add To Cart button text sizeYou just omitted the last
"by accident aftermargin: 1rem 0;🙂I should be
margin: 1rem 0;"Forum: Plugins
In reply to: [WooCommerce] Change after Add To Cart button text sizeCan you please paste your code again? Please use the “CODE”-tags in the editor.
Any input on this?
Forum: Plugins
In reply to: [WooCommerce] Change after Add To Cart button text sizeadd_action( ‘woocommerce_after_add_to_cart_button’, ‘add_content_after_addtocart_button_func’ ); function add_content_after_addtocart_button_func() { // Echo content. echo ‘<div class="second_content" style="font-size: 14px; line-height: 1.2; font-weight: 600; margin: 1rem 0;"> <--- HERE :)Free and fast shipping, 24 hour customer service, Lifetime warranty and easy returns</div>’; }I’ve noted the place in your code above 🙂
Forum: Plugins
In reply to: [WooCommerce] Change after Add To Cart button text sizeIf you don’t want to do it in the style.css you can do it inside the HTML-tag itself.
<div class="second_content" style="font-size: 14px; line-height: 1.2; font-weight: 600; margin: 1rem 0;">Forum: Plugins
In reply to: [WooCommerce] set_price() not working in nested foreachDoes anybody know if
set_priceshould be persistent?Forum: Plugins
In reply to: [WooCommerce] Change after Add To Cart button text sizeHave you tried adding CSS to your style.css file?
.second_content { //your css here font-size: 10px; margin-top: 10px; color: #2c2c2c; }- This reply was modified 5 years, 8 months ago by Dekadinious. Reason: typo
Forum: Plugins
In reply to: [WooCommerce] set_price() not working in nested foreachOkay, now I have tried to run the minimal amount of code here in a fresh install with Storefront and no plugins.
foreach ($cart->get_cart() as $cart_item_key => $cart_item) { $id = $cart_item['product_id']; $quantity = $cart_item['quantity']; if ($quantity < 3) { return; } //Split 1 of the item //Set quantity to quantity - 1 for the item $cart->set_quantity($cart_item_key, $quantity - 1); //Get variation vars $variation_id = $cart_item['variation_id']; $variation = $cart_item['variation']; //Add the product as a new line item with the same variations that were passed $item_key = $cart->add_to_cart($id, 1, $variation_id, $variation, $cart_item); //Set the price to be free $cart->get_cart()[$item_key]['data']->set_price('0'); }If I comment out the
returninside the if-statement, it works. I get three split items, of course, but it sets the price to 0 for all of them.If I have this
returnpresent, it splits out one item like I want it to do, but the price is not set to 0.If I log the price on the last line, my log shows the price is set to 0. Why then, does the cart not reflect this?
How does
set_pricework? Is it not persistent? Does it not set the price in the cart for the session in the database?It seems the code execution has to reach
set_pricefor each time thewoocommerce_before_calculate_totalshook runs. But in this case, it won’t do that, because the quantity will only be >3 on the first run of the hook.So it will reach
set_pricewhen in the AJAX-call that updates the cart, but it won’t reach it when the page reloads. If setting the price was persistent for the session, this should not be a problem.How would you set the price of a dynamically added item like this?
It’s just a custom taxonomy that’s hierarchical.
Forum: Plugins
In reply to: [WooCommerce] Stack trace on compatibility issuesThanks!
Forum: Plugins
In reply to: [WooCommerce] Product stock suddenly drops to 0 (during checkout?)I found the issue. It was indeed a new change to a code made by one of our consultants.
Thank you!