Change size from woocommerce PayPal checkout button in cart - button

I use the WooCommerce PayPal Checkout Gateway Plugin.
In the Backend of wordpress I set the default button-size: medium.
Trying to change the css through childtheme css or the plugins wc-gateway-ppec-frontend.css isn't possible.
Someone has any solution?

That PayPal image is being loaded from Paypal’s servers. So in order to change it you will have to modify the plugin code.
For PayPal button shape in checkout page navigate to: (line 46)
wp-content/plugins/woocommerce-gateway-paypal-powered-by-braintree/includes/payment-forms/class-wc-braintree-paypal-payment-form.php
For PayPal button shape in cart page navigate to: (line 141)
wp-content/plugins/woocommerce-gateway-paypal-powered-by-braintree/includes/class-wc-braintree-paypal-cart.php
$default_button_styles = array(
label: 'checkout', // pay | paypal | buynow | checkout | credit
size: 'responsive', // small | medium | large | responsive
shape: 'rect', // pill | rect
color: 'gold', // gold | blue | silver | black
tagline: false, // true | false
fundingicons: true, // true | false
);
Use the below code in your functions.php file. Upload a Custom Paypal Logo in your Media Library and then replace that URL in "$express_checkout_img_url" in the below function.
// Hook in
add_filter( ‘woocommerce_paypal_express_checkout_button_img_url’ , ‘custom_override_woocommerce_paypal_express_checkout_button_img_url’ );
// Our hooked in function – $fields is passed via the filter!
function custom_override_woocommerce_paypal_express_checkout_button_img_url( $variablen ) {
$express_checkout_img_url = '/wp-content/themes/XXXXXX/images/M3_Logo_01.jpg';
return $express_checkout_img_url;
}
Check below URLs for some other ideas:
https://docs.woocommerce.com/document/paypal-express-checkout/#section-7
https://isabelcastillo.com/change-woocommerce-paypal-icon-to-custom-image-with-credit-card-icons

Related

Change items tax rate in WooCommerce order admin based on custom field

My customers have to make a choice during the checkout to select if they are vat exempted or not. i use custom fields. I tried 3 solutions, all worked well:
Change items tax rate in WooCommerce checkout based on radio buttons
Add Tax Exempt form on checkout in woocommerce
and the best for me:
`
add_action( 'woocommerce_checkout_update_order_review', 'bbloomer_taxexempt_checkout_based_on_zip' );
function bbloomer_taxexempt_checkout_based_on_zip( $post_data ) {
WC()->customer->set_is_vat_exempt( false );
parse_str( $post_data, $output );
if ( $output['fsbdd_check_exotva'] === 'OUI' ) WC()->customer->set_is_vat_exempt( true );
}
`
But I can't change this setting in the woocommerce order admin page. if the customer was wrong or I need to edit the order manually I would like the VAT to change depending on this custom field.
I can manage the custom field with a metabox in the order backend (from metabox.io plugin). But there is no effect on the VAT. i would like the cart to be recalculate (recalculate button) once I have changed and saved the custom field value.

How to hide my-account menu on certain pages in Woocommerce?

When logged in with Woocommerce, is there a way to only render the dashboard menu when on the index page of the logged in "mode"?
I only want to display it on "dashboard". Not on "orders", "downloads", "addresses" or the other pages.
I don't want to do it with CSS.
I have copied the template files, so i'll post the dashboard and orders templates.
dashboard.php
https://github.com/woocommerce/woocommerce/blob/master/templates/myaccount/dashboard.php
orders.php
https://github.com/woocommerce/woocommerce/blob/master/templates/myaccount/downloads.php
Instead of making changes to template files, you can use the
woocommerce_account_navigation action hook
So you get:
function action_woocommerce_account_navigation () {
// Detect the WC Dashboard page, and if NOT
if ( is_user_logged_in() && is_account_page() && is_wc_endpoint_url() ) {
// Remove navigation
remove_action( 'woocommerce_account_navigation', 'woocommerce_account_navigation' );
}
}
add_action( 'woocommerce_account_navigation', 'action_woocommerce_account_navigation', 1, 0 );

Woocommerce how to click a button to add to cart and checkout?

Objective:
I would like the customer to click on a button, add an item with quantity = 1 to cart, and route to checkout page automatically.
What I did:
I'm using Elementor to add a button with a href value of:
https://fakeurl.com/checkout/?add-to-cart=59
Problem:
Once I click the button, it will route to the checkout page, however it will add 2 quantity instead of one to the cart.
What I've tried:
Explicitly specify the quantity count in the href:
https://fakeurl.com/checkout?add-to-cart=59&quantity=1
But I'm getting the same results.
My checkout page is just simple page with 2 shortcodes namely woocommerce_cart & woocommerce_checkout:
Any idea why? Do I need to empty the cart before the aforementioned button is pressed?
Use your link structure as you already do > ?add-to-cart=59&quantity=1 and add below code in functions.php in your theme to just do checking
the only thing this peace of code do is to loop your cart to see if this product is already there .. and if it is - it sets $valid var on false
function is_product_in_cart( $valid, $product_id, $quantity) {
global $woocommerce;
if($woocommerce->cart->cart_contents_count == 0) return true;
foreach ( $woocommerce->cart->get_cart() as $key => $values ) {
$_product = $values['data'];
$id = $_product->id ;
if( $product_id == $id ) $valid = false;
}
return $valid;
}
add_filter( 'woocommerce_add_to_cart_validation', 'is_product_in_cart', 10, 3 );
Woocommerce default flow is that it will add the quantity to the cart whenever you add an item that is already in the cart.
Empty your cart whenever a new product is added to the cart so that only one remains in the cart.
In most cases the quantity is doubled because you are being redirected.
So the quantity is added and after the redirect the quantity is added again.
The reasons for this could be a couple of the things.
Theme or wordpress permalinks setting are adding or removing // in the links
Your checkout page is not set in woocommerce settings (woocommerce->advanced settings->Page settings)
How to check if you are being redirected (chrome)
At the top of Chrome's inspector (in the Network tab) is a checkbox which says Preserve log. Enable this option. Now it doesn't matter at all how the page navigates, the inspector will keep all log history -- including the redirect response.
(found here: See full redirect path and HTTP status code in Chrome)
Possible solutions
“Enable AJAX add to cart buttons on archives” (WooCommerce –> Settings –> Products -> General)
found here (https://www.businessbloomer.com/woocommerce-custom-add-cart-urls-ultimate-guide/)
This sometimes help when having custom pages for cart and checkout.
Disable "Redirect to the cart page after successful addition" under WooCommerce > Settings > Products.Because you are linking to the checkout page, this wil redirect you again to the cart page.

Woocommerce cropping not working as it should?

I have tried just about everything I can find on the internet. Here are my current woocommerce cropping settings:
The problem is, after I re-generate the images and I go back to this page, I end up with this:
Why would it do this and how can I fix it?
UPDATE
In fact, it doesn't reset the hard crop settings after I regenerate the images. It simply saves it as "hard crop" checked after I uncheck them, even though it initially shows that I've changed it?
UPDATE 2
It seems to be related to this.
UPDATE 3
I tried adding this:
add_action( 'aftersetup_theme', function () {
// Add image sizes
$shop_thumbnail = wc_get_image_size( 'shop_thumbnail' );
$shop_catalog = wc_get_image_size( 'shop_catalog' );
$shop_single = wc_get_image_size( 'shop_single' );
// In the lines below, true = hard crop; false = proportional
$shop_thumbnail['crop'] = false;
$shop_catalog['crop'] = false;
$shop_single['crop'] = false;
add_image_size( 'shop_thumbnail', $shop_thumbnail['width'], $shop_thumbnail['height'], $shop_thumbnail['crop'] );
add_image_size( 'shop_catalog', $shop_catalog['width'], $shop_catalog['height'], $shop_catalog['crop'] );
add_image_size( 'shop_single', $shop_single['width'], $shop_single['height'], $shop_single['crop'] );
}, 20 );
And then I re-generated the images, and still no luck?
UPDATE 4:
The site can be viewed here:
http://www.diamondcouturelondon.co.uk/
UPDATE 5:
The plugins installed include:
Contact Form 7
Lollum Framework
oAuth Twitter Feed for Developers
Regenerate Thumbnails
Revolution Slider
WooCommerce
YITH WooCommerce Wishlist
UPDATE 6:
I disabled ALL the plugins except for WooCommerce. I then went to this page:
/wp-admin/admin.php?page=wc-settings&tab=products
There I again unchecked "hard crop" next to all items. I pressed save. Upon reload, the items are unchecked, but if I refresh the page, they are checked. So the changes weren't saved. In other words, WITH ONLY WOOCOMMERCE enabled, it STILL doesn't save my hard crop settings.
That leaves me with only one other possible external influence --> the theme. But I can't see how that can be affecting it.
Can you try this ?
add_filter( 'woocommerce_get_image_size_shop_thumbnail', 'force_crop_woocommerce' );
add_filter( 'woocommerce_get_image_size_shop_catalog', 'force_crop_woocommerce' );
add_filter( 'woocommerce_get_image_size_shop_single', 'force_crop_woocommerce' );
function force_crop_woocommerce( $size ){
$size['crop'] = 0;
return $size;
}

How do you make a Wordpress plugin have "per post" options?

I'm building a Wordpress blog that requires a custom slideshow system with an admin panel on each post admin page (sort of like how Yoast's SEO plugin has options on each page).
How would I make the admin options appear on the post admin page?
Thanks,
Charlie
You are not providing much detail about your project but you probably want to make some meta_boxes and save the data to as custom fields.
Here is a truncated example culled from something I put together for a question at wordpress.stackexchange. The details of some of the functions are not important for your question here but it illustrates the general 'how'. Follow the link for working but sincerely beta code.
// author checkboxes
add_action( 'add_meta_boxes', 'assisting_editor' );
function assisting_editor() {
add_meta_box(
'assisting_editor', // id, used as the html id att
__( 'Editorial Tasks' ), // meta box title
'editor_tasks', // callback function, spits out the content
'post', // post type or page. This adds to posts only
'side', // context, where on the screen
'low' // priority, where should this go in the context
);
}
// this is the callback that creates the meta box content
function editor_tasks( $post ) {
// function details skipped; follow the link
}
// to save the data
add_action( 'save_post', 'save_metadata');
// callback for the save hook ^^
function save_metadata($postid) {
// function details skipped; follow the link
}

Resources