Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.2.5.2 #240

Merged
merged 2 commits into from
Sep 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions assets/js/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -1804,8 +1804,12 @@ jQuery(function($) {
/**
* keyup is actually for total price live changing
* When someone type quantity then total price will change live
* if($('#table_id_' + table_id + ' .wpt_total').length > 0){
inputBoxChangeHandle();
}
*/
$(document).on('keyup','.wpt_row input.input-text.qty.text', inputBoxChangeHandle);
// $(document).on('keyup','.wpt_row input.input-text.qty.text', inputBoxChangeHandle);
$(document).on('keyup','.wpt_row input.input-text.qty.text', oneSecondDelay(inputBoxChangeHandle,1500));

$('body').on('change', '.wpt_row input.input-text.qty.text', inputBoxChangeHandle);
function inputBoxChangeHandle() {
Expand All @@ -1815,12 +1819,12 @@ jQuery(function($) {

var thisRow = '#table_id_' + temp_number + ' tr.product_id_' + product_id;

$( thisRow + 'input.input-text.qty.text').val(Qty_Val); // input.input-text.qty.text
$( thisRow + ' input.input-text.qty.text').val(Qty_Val); // input.input-text.qty.text
$( thisRow ).attr('data-quantity', Qty_Val);
$( thisRow + 'a.wpt_woo_add_cart_button').attr('data-quantity', Qty_Val);
$( thisRow + 'a.add_to_cart_button').attr('data-quantity', Qty_Val);
$( thisRow + ' a.wpt_woo_add_cart_button').attr('data-quantity', Qty_Val);
$( thisRow + ' a.add_to_cart_button').attr('data-quantity', Qty_Val);
var Item_URL = '?add-to-cart=' + product_id + '&quantity=' + Qty_Val;
$( thisRow + 'a.add_to_cart_button').attr('href', Item_URL);
$( thisRow + ' a.add_to_cart_button').attr('href', Item_URL);
var targetTotalSelector = $('#table_id_' + temp_number + ' .product_id_' + product_id + ' .wpt_total_item.total_general');


Expand Down
9 changes: 6 additions & 3 deletions assets/js/wpt-control.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jQuery(function($) {
url: ajax_url,
data: data,
success:function(result){
// $('.wpt_edit_table').html(result);
$('.wpt_edit_table').html(result);
if ( result ) {
$.each( result, function( key, value ) {
if('string' === typeof key){
Expand Down Expand Up @@ -64,7 +64,6 @@ jQuery(function($) {

var table_id = thisPagination.data('table_id');
var args = getSearchQueriedArgs( table_id );
console.log(args);

ajaxTableLoad(table_id, args, page_number );

Expand All @@ -82,7 +81,10 @@ jQuery(function($) {
});

function getSearchQueriedArgs( table_id ){
let value,key;
let value,key,base_link;

//On ajax search, Page link shown with ajax link, we will send this base link, so that always can get smart link
base_link = $('.wpt-my-pagination-' + table_id ).data('base_link');
var texonomies = {};
value = false;
$('#search_box_' + table_id + ' .search_select.query').each(function(){
Expand Down Expand Up @@ -146,6 +148,7 @@ jQuery(function($) {
s: s,
tax_query: tax_query,
meta_query: meta_query,
base_link:base_link,
};
return args;
}
Expand Down
6 changes: 3 additions & 3 deletions inc/handle/pagination.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@

class Pagination{
public static function render( Shortcode $shortcode ){

?>
<div class='wpt_my_pagination wpt_table_pagination' data-table_id='<?php echo $shortcode->table_id; ?>'>
<div data-base_link="<?php echo esc_attr( $shortcode->pagination_base_url ); ?>" class='wpt_my_pagination wpt-my-pagination-<?php echo $shortcode->table_id; ?> wpt_table_pagination' data-table_id='<?php echo $shortcode->table_id; ?>'>
<?php
echo self::get_paginate_links( $shortcode );
?>
Expand All @@ -18,13 +19,12 @@ public static function render( Shortcode $shortcode ){
public static function get_paginate_links( Shortcode $shortcode ){
$args = $shortcode->args;
$product_loop = new \WP_Query($args);
$big = 99999999;

/**
* @Hook Filter for pagination
*/
$paginate_args = apply_filters('wpt_paginate_args', array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'base' => $shortcode->pagination_base_url,
'format' => apply_filters( 'wpto_pagination_format', '?paged=%#%', $args ),
'mid_size' => 3,
'prev_next' => false,
Expand Down
13 changes: 13 additions & 0 deletions inc/shortcode-ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,19 @@ public function wpt_load_both(){


$page_number = $_POST['page_number'] ?? $this->page_number;

/**
* Actually base link is not part of Args. but we take it
* using args when call ajax
* to set right link
* on pagination. otherwise, it was shown link
* like: example.com/wp-admin/wp-ajax.php?page=2
*
* but now it wll show page linke: example.com/page/2
* @since 3.2.5.2
*/
$this->pagination_base_url = $_POST['args']['base_link'] ?? null;

$this->args['paged'] = $this->page_number = $page_number;

/**
Expand Down
10 changes: 9 additions & 1 deletion inc/shortcode-base.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class Shortcode_Base extends Base{
public $items_directory;
public $items_permanent_dir;

public $data;


protected function unsetArrayItem( Array $arr, $unset_item ){
if( ! isset( $arr[$unset_item] ) ) return $arr;
Expand Down Expand Up @@ -40,5 +42,11 @@ public function get_meta( string $meta_key ){
return is_array( $data ) ? $data : [];
}


public function __get( $name ){
return $this->data[$name] ?? null;
}

public function __set($name, $value){
$this->data[$name] = $value;
}
}
7 changes: 3 additions & 4 deletions inc/shortcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ class="<?php echo esc_attr( Table_Attr::table_class( $this ) ); ?>">

<?php
if( $this->pagination ){
$big = 99999999;
$this->pagination_base_url = str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) );

Pagination::render( $this );
}

Expand Down Expand Up @@ -486,10 +489,6 @@ protected function table_head(){
<?php

}

public function pagination_render(){
echo wpt_pagination_by_args( $this->args , $this->table_id, ['args' => $this->args]);
}

/**
* Basically for main search box and Meta field wise search box.
Expand Down