-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4d5cbc9
commit 82fe76c
Showing
9 changed files
with
692 additions
and
79 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
inc/Builders/Elementor/Shortcodes/WooCommerce/ProductAddToCart.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<?php | ||
|
||
namespace WPEssential\Plugins\ElementorBlocks\Builders\Elementor\Shortcodes\WooCommerce; | ||
|
||
if ( ! \defined( 'ABSPATH' ) ) { | ||
exit; // Exit if accessed directly. | ||
} | ||
|
||
use Elementor\Controls_Manager; | ||
use WPEssential\Plugins\Builders\Fields\RawHtml; | ||
|
||
class ProductAddToCart extends WCCategory | ||
{ | ||
/** | ||
* Set widget keywords. | ||
* Retrieve widget keywords. | ||
* | ||
* @return array Widget keywords. | ||
* @access public | ||
* @since 1.0.0 | ||
* @public | ||
*/ | ||
public function set_keywords () | ||
{ | ||
return [ 'woocommerce', 'shop', 'store', 'cart', 'product', 'button', 'add to cart' ]; | ||
} | ||
|
||
/** | ||
* Register widget controls. | ||
* | ||
* Adds different input fields to allow the user to change and customize the widget settings. | ||
* | ||
* @since 1.0.0 | ||
* @access public | ||
*/ | ||
public function register_controls () | ||
{ | ||
$this->start_controls_section( | ||
'section_1', | ||
[ | ||
'label' => __( 'Layout', 'wpessential' ) | ||
] | ||
); | ||
|
||
$this->add_control( | ||
'product_id', | ||
[ | ||
'label' => esc_html__( 'Product', 'elementor-pro' ), | ||
'type' => Controls_Manager::SELECT, | ||
'options' => wpe_get_posts( [ 'post_type' => 'product', 'posts_per_page' => - 1 ] ), | ||
] | ||
); | ||
|
||
$this->end_controls_section(); | ||
|
||
$this->start_controls_section( | ||
'section_pro_wc', | ||
[ | ||
'label' => __( 'Pro', 'wpessential' ) | ||
] | ||
); | ||
|
||
$opt = RawHtml::make( __( 'WooCommerce', 'wpessential' ) ) | ||
->data( __( 'There are no option found. If you want more options, then please try the Pro version.', 'wpessential' ), ) | ||
->toArray(); | ||
$this->add_control( $opt[ 'id' ], $opt ); | ||
|
||
$this->end_controls_section(); | ||
|
||
} | ||
|
||
/** | ||
* Render widget output on the frontend. | ||
* | ||
* Written in PHP and used to generate the final HTML. | ||
* | ||
* @since 1.0.0 | ||
* @access public | ||
*/ | ||
public function render () | ||
{ | ||
global $product; | ||
|
||
if ( ! is_product() ) { | ||
global $post; | ||
$product = wc_get_product( $this->get_settings( 'product_id' ) ); | ||
$post = get_post( $product->get_id() ); | ||
} | ||
else { | ||
$product = wc_get_product(); | ||
} | ||
|
||
if ( empty( $product ) ) { | ||
return; | ||
} | ||
?> | ||
<div class="wpe-add-to-cart wpe-product-<?php echo esc_attr( $product->get_type() ); ?>"> | ||
<?php woocommerce_template_single_add_to_cart(); ?> | ||
</div> | ||
<?php | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters