{"id":2346,"date":"2015-04-09T12:30:35","date_gmt":"2015-04-09T12:30:35","guid":{"rendered":"http:\/\/musilda.cz\/?p=2346"},"modified":"2015-04-09T12:30:35","modified_gmt":"2015-04-09T12:30:35","slug":"minimalni-cena-objednavky-ve-woocommerce","status":"publish","type":"post","link":"https:\/\/affinite.io\/cs\/minimalni-cena-objednavky-ve-woocommerce\/","title":{"rendered":"Minim\u00e1ln\u00ed cena objedn\u00e1vky ve WooCommerce"},"content":{"rendered":"
Pokud nab\u00edz\u00edte v eshopu specifick\u00e9 zbo\u017e\u00ed a chcete n\u00e1kup podm\u00ednit minim\u00e1ln\u00ed \u010d\u00e1stkou, kterou je pot\u0159eba utratit, aby bylo v\u016fbec mo\u017eno nakoupit, bude se v\u00e1m hodin n\u00e1sleduj\u00edc\u00ed snippet.<\/p>\n
Op\u011bt, stejn\u011b jako v jin\u00fdch p\u0159\u00edpadech, pou\u017eijeme vestav\u011bn\u00e9 akce, kter\u00e9 m\u00e1 WooCommerce v hojn\u00e9m mno\u017estv\u00ed.
Tenotkr\u00e1t to bude woocommerce_checkout_process a woocommerce_before_cart.<\/p>\n
Do functions.php p\u0159id\u00e1me n\u00e1sleduj\u00edc\u00ed k\u00f3d.<\/p>\n
add_action( 'woocommerce_checkout_process', 'wc_minimum_order_amount' );\nadd_action( 'woocommerce_before_cart' , 'wc_minimum_order_amount' );\n\nfunction wc_minimum_order_amount() {\n $minimum = 50;\n\n if ( WC()->cart->total < $minimum ) {\n\n if( is_cart() ) {\n\n wc_print_notice(\n sprintf( 'You must have an order with a minimum of %s to place your order, your current order total is %s.' ,\n wc_price( $minimum ),\n wc_price( WC()->cart->total )\n ), 'error'\n );\n\n } else {\n\n wc_add_notice(\n sprintf( 'You must have an order with a minimum of %s to place your order, your current order total is %s.' ,\n wc_price( $minimum ),\n wc_price( WC()->cart->total )\n ), 'error'\n );\n\n }\n }\n\n}\n<\/pre>\nTento k\u00f3d sleduje celkovou hodnotu objedn\u00e1vky, co\u017e znamen\u00e1, \u017ee zapo\u010d\u00edt\u00e1v\u00e1 i cenu dopravy.
Pokud chcete m\u00edt \u010distou hodnotu ko\u0161\u00edku, mus\u00edte zm\u011bnit v\u0161echny z\u00e1pisy WC()->cart->total na WC()->cart->subtotal<\/p>\n\n\n